Skip to content

Commit f1f5b18

Browse files
committed
Ignore '=' or '.' if it is inside string or comment
1 parent 364b0ad commit f1f5b18

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

php-mode.el

+15-9
Original file line numberDiff line numberDiff line change
@@ -868,6 +868,15 @@ This is was done due to the problem reported here:
868868
"See `php-c-at-vsemi-p'."
869869
)
870870

871+
(defsubst php-in-string-p ()
872+
(nth 3 (syntax-ppss)))
873+
874+
(defsubst php-in-comment-p ()
875+
(nth 4 (syntax-ppss)))
876+
877+
(defsubst php-in-string-or-comment-p ()
878+
(nth 8 (syntax-ppss)))
879+
871880
(defun php-lineup-string-cont (langelem)
872881
"Line up string toward equal sign or dot
873882
e.g.
@@ -876,9 +885,12 @@ $str = 'some'
876885
this ^ lineup"
877886
(save-excursion
878887
(goto-char (cdr langelem))
879-
(when (or (search-forward "=" (line-end-position) t)
880-
(search-forward "." (line-end-position) t))
881-
(vector (1- (current-column))))))
888+
(let (ret finish)
889+
(while (and (not finish) (re-search-forward "[=.]" (line-end-position) t))
890+
(unless (php-in-string-or-comment-p)
891+
(setq finish t
892+
ret (vector (1- (current-column))))))
893+
ret)))
882894

883895
(defun php-lineup-arglist-intro (langelem)
884896
(save-excursion
@@ -911,12 +923,6 @@ the string HEREDOC-START."
911923
(string-match "\\w+" heredoc-start)
912924
(concat "^\\(" (match-string 0 heredoc-start) "\\)\\W"))
913925

914-
(defsubst php-in-string-p ()
915-
(nth 3 (syntax-ppss)))
916-
917-
(defsubst php-in-comment-p ()
918-
(nth 4 (syntax-ppss)))
919-
920926
(defun php-syntax-propertize-function (start end)
921927
"Apply propertize rules from START to END."
922928
;; (defconst php-syntax-propertize-function

0 commit comments

Comments
 (0)