@@ -245,7 +245,7 @@ Look at the `php-executable' variable instead of the constant \"php\" command."
245245 'flymake-php-init )))))
246246 (list php-executable (cdr init))))
247247
248- (defconst php-re-detect-html-tag
248+ (defconst php-re-detect-html-tag-aggressive
249249 (eval-when-compile
250250 (rx (or (: string-start (* (in space))
251251 " <!"
@@ -257,13 +257,37 @@ Look at the `php-executable' variable instead of the constant \"php\" command."
257257 (* (in space)) (+ (in alpha " -" )) (* (in space)) " >" ))
258258 (: " <" (* (in space)) (+ (in alpha " -" )) (* (in space)) " >" ))))))
259259
260+ (defconst php-re-detect-html-tag-default
261+ (eval-when-compile
262+ (rx (or (: string-start (* (in space))
263+ " <!"
264+ (or " DOCTYPE" " doctype" )
265+ (+ (in space))
266+ (or " HTML" " html" ))
267+ (: line-start
268+ (: " <" (* (in space)) (+ (in alpha " -" )) (* (in space)) " >" ))))))
269+
270+ (defcustom php-re-detect-html-tag 'php-re-detect-html-tag-default
271+ " Regexp pattern variable-name of HTML detection."
272+ :group 'php
273+ :type '(choice (const 'php-re-detect-html-tag-default :tag " Default pattern" )
274+ (const 'php-re-detect-html-tag-aggressive :tag " Aggressive pattern" )
275+ (variable :tag " Variable name of RegExp pattern" )))
276+
277+ (defsubst php-re-detect-html-tag ()
278+ " Return RegExp pattern for HTML detection."
279+ (if (symbolp php-re-detect-html-tag)
280+ (symbol-value php-re-detect-html-tag)
281+ php-re-detect-html-tag))
282+
260283(defun php-buffer-has-html-tag ()
261284 " Return position of HTML tag or NIL in current buffer."
262285 (save-excursion
263286 (save-restriction
264287 (widen )
265288 (goto-char (point-min ))
266- (re-search-forward php-re-detect-html-tag nil t ))))
289+ (save-match-data
290+ (re-search-forward (php-re-detect-html-tag) nil t )))))
267291
268292(defun php-derivation-major-mode ()
269293 " Return major mode for PHP file by file-name and its content."
0 commit comments