@@ -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,38 @@ 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+ :tag " PHP Re Detect HTML Tag"
274+ :type '(choice (const :tag " Default pattern" 'php-re-detect-html-tag-default )
275+ (const :tag " Aggressive pattern" 'php-re-detect-html-tag-aggressive )
276+ (variable :tag " Variable name of RegExp pattern" )))
277+
278+ (defsubst php-re-detect-html-tag ()
279+ " Return RegExp pattern for HTML detection."
280+ (if (symbolp php-re-detect-html-tag)
281+ (symbol-value php-re-detect-html-tag)
282+ php-re-detect-html-tag))
283+
260284(defun php-buffer-has-html-tag ()
261285 " Return position of HTML tag or NIL in current buffer."
262286 (save-excursion
263287 (save-restriction
264288 (widen )
265289 (goto-char (point-min ))
266- (re-search-forward php-re-detect-html-tag nil t ))))
290+ (save-match-data
291+ (re-search-forward (php-re-detect-html-tag) nil t )))))
267292
268293(defun php-derivation-major-mode ()
269294 " Return major mode for PHP file by file-name and its content."
0 commit comments