Skip to content

Commit 1e2009a

Browse files
committed
Revert "Optimize php-mode--string-interpolated-variable-font-lock-find"
This reverts commit 9abc38b.
1 parent b949915 commit 1e2009a

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

lisp/php-mode.el

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1451,9 +1451,7 @@ for \\[find-tag] (which see)."
14511451

14521452
;; Logical operators (and, or, &&, ...)
14531453
;; Not operator (!) is defined in "before cc-mode" section above.
1454-
("\\(&&\\|||\\)" 1 'php-logical-op)
1455-
;; string interpolation ("$var, ${var}, {$var}")
1456-
(php-mode--string-interpolated-variable-font-lock-find 0 nil)))
1454+
("\\(&&\\|||\\)" 1 'php-logical-op)))
14571455
"Detailed highlighting for PHP Mode.")
14581456

14591457
(defvar php-font-lock-keywords php-font-lock-keywords-3
@@ -1485,15 +1483,22 @@ The output will appear in the buffer *PHP*."
14851483
(defconst php-string-interpolated-variable-regexp
14861484
"{\\$[^}\n\\\\]*\\(?:\\\\.[^}\n\\\\]*\\)*}\\|\\${\\sw+}\\|\\$\\sw+")
14871485

1488-
(defun php-mode--string-interpolated-variable-font-lock-find (limit)
1489-
"Apply text-property to LIMIT for string interpolation by font-lock."
1490-
(let (quoted-stuff)
1491-
(while (re-search-forward php-string-interpolated-variable-regexp limit t)
1492-
(setq quoted-stuff (php-in-string-p))
1486+
(defun php-string-intepolated-variable-font-lock-find (limit)
1487+
(while (re-search-forward php-string-interpolated-variable-regexp limit t)
1488+
(let ((quoted-stuff (nth 3 (syntax-ppss))))
14931489
(when (or (eq ?\" quoted-stuff) (eq ?` quoted-stuff))
1494-
(put-text-property (match-beginning 0) (match-end 0) 'face 'php-variable-name))))
1490+
(put-text-property (match-beginning 0) (match-end 0)
1491+
'face 'php-variable-name))))
14951492
nil)
1493+
1494+
(eval-after-load 'php-mode
1495+
'(progn
1496+
(font-lock-add-keywords
1497+
'php-mode
1498+
`((php-string-intepolated-variable-font-lock-find))
1499+
'append)))
14961500

1501+
14971502
;;; Correct the behavior of `delete-indentation' by modifying the
14981503
;;; logic of `fixup-whitespace'.
14991504
(defun php-mode--fixup-whitespace-after ()

0 commit comments

Comments
 (0)