Skip to content

Commit 961a0c7

Browse files
committed
Impl php-buffer-has-html-tag
1 parent b69be5f commit 961a0c7

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

Diff for: php.el

+20
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,26 @@ Look at the `php-executable' variable instead of the constant \"php\" command."
216216
'flymake-php-init)))))
217217
(list php-executable (cdr init))))
218218

219+
(defconst php-re-detect-html-tag
220+
(eval-when-compile
221+
(rx (or (: string-start (* (in space))
222+
"<!"
223+
(or "DOCTYPE" "doctype")
224+
(+ (in space))
225+
(or "HTML" "html"))
226+
(: (or line-start
227+
(: "<" (? "/")
228+
(* (in space)) (+ (in alpha "-")) (* (in space)) ">"))
229+
(: "<" (* (in space)) (+ (in alpha "-")) (* (in space)) ">"))))))
230+
231+
(defun php-buffer-has-html-tag ()
232+
"Return position of HTML tag or NIL in current buffer."
233+
(save-excursion
234+
(save-restriction
235+
(widen)
236+
(goto-char (point-min))
237+
(re-search-forward php-re-detect-html-tag nil t))))
238+
219239
;;;###autoload
220240
(defun php-mode-maybe ()
221241
"Select PHP mode or other major mode."

0 commit comments

Comments
 (0)