@@ -974,26 +974,37 @@ this ^ lineup"
974
974
(goto-char (point-max )))
975
975
(c-put-char-property (1- (point )) 'syntax-table (string-to-syntax " |" )))
976
976
977
+ (defvar-local php-mode--propertize-extend-region-current nil
978
+ " Prevent undesirable recursion in PHP-SYNTAX-PROPERTIZE-EXTEND-REGION" )
979
+
977
980
(defun php-syntax-propertize-extend-region (start end )
978
981
" Extend the propertize region if START or END falls inside a PHP heredoc."
979
- (let ((new-start)
980
- (new-end))
981
- (goto-char start)
982
- (when (re-search-backward php-heredoc-start-re nil t )
983
- (let ((maybe (point )))
984
- (when (and (re-search-forward
985
- (php-heredoc-end-re (match-string 0 )) nil t )
986
- (> (point ) start))
987
- (setq new-start maybe))))
988
- (goto-char end)
989
- (when (re-search-backward php-heredoc-start-re nil t )
990
- (if (re-search-forward
991
- (php-heredoc-end-re (match-string 0 )) nil t )
992
- (when (> (point ) end)
993
- (setq new-end (point )))
994
- (setq new-end (point-max ))))
995
- (when (or new-start new-end)
996
- (cons (or new-start start) (or new-end end)))))
982
+ (let ((pair (cons start end)))
983
+ (when (not (member pair php-mode--propertize-extend-region-current))
984
+ ; ; re-search functions may trigger
985
+ ; ; syntax-propertize-extend-region-functions to be called again, which in
986
+ ; ; turn call this to be called again.
987
+ (push pair php-mode--propertize-extend-region-current)
988
+ (unwind-protect
989
+ (let ((new-start)
990
+ (new-end))
991
+ (goto-char start)
992
+ (when (re-search-backward php-heredoc-start-re nil t )
993
+ (let ((maybe (point )))
994
+ (when (and (re-search-forward (php-heredoc-end-re (match-string 0 )) nil t )
995
+ (> (point ) start))
996
+ (setq new-start maybe))))
997
+ (goto-char end)
998
+ (when (re-search-backward php-heredoc-start-re nil t )
999
+ (if (re-search-forward (php-heredoc-end-re (match-string 0 )) nil t )
1000
+ (when (> (point ) end)
1001
+ (setq new-end (point )))
1002
+ (setq new-end (point-max ))))
1003
+ (when (or new-start new-end)
1004
+ (cons (or new-start start) (or new-end end))))
1005
+ ; ; Cleanup
1006
+ (setq php-mode--propertize-extend-region-current
1007
+ (delete pair php-mode--propertize-extend-region-current))))))
997
1008
998
1009
(easy-menu-define php-mode-menu php-mode-map " PHP Mode Commands"
999
1010
(cons " PHP" (c-lang-const c-mode-menu php)))
0 commit comments