7272(require 'speedbar )
7373(require 'imenu )
7474(require 'package )
75- (require 'nadvice nil t )
75+ (require 'nadvice )
7676
7777(require 'cl-lib )
7878(require 'mode-local )
8585 (defvar c-vsemi-status-unknown-p )
8686 (defvar syntax-propertize-via-font-lock ))
8787
88- ; ; Work around emacs bug#18845, cc-mode expects cl to be loaded
89- ; ; while php-mode only uses cl-lib (without compatibility aliases)
90- (eval-and-compile
91- (when (and (= emacs-major-version 24 ) (>= emacs-minor-version 4 ))
92- (require 'cl )))
93-
94- ; ; Work around https://github.com/emacs-php/php-mode/issues/310.
95- ; ;
96- ; ; In emacs 24.4 and 24.5, lines after functions with a return type
97- ; ; are incorrectly analyzed as member-init-cont.
98- ; ;
99- ; ; Before emacs 24.4, c member initializers are not supported this
100- ; ; way. Starting from emacs 25.1, cc-mode only detects member
101- ; ; initializers when the major mode is c++-mode.
102- (eval-and-compile
103- (if (and (= emacs-major-version 24 ) (or (= emacs-minor-version 4 )
104- (= emacs-minor-version 5 )))
105- (defun c-back-over-member-initializers ()
106- ; ; Override of cc-engine.el, cc-mode in emacs 24.4 and 24.5 are too
107- ; ; optimistic in recognizing c member initializers. Since we don't
108- ; ; need it in php-mode, just return nil.
109- nil )))
110-
11188(autoload 'php-mode-debug " php-mode-debug"
11289 " Display informations useful for debugging PHP Mode." t )
11390
@@ -1022,8 +999,7 @@ this ^ lineup"
1022999 ; ; turn call this to be called again.
10231000 (push pair php-mode--propertize-extend-region-current)
10241001 (unwind-protect
1025- (let ((new-start)
1026- (new-end))
1002+ (let (new-start new-end)
10271003 (goto-char start)
10281004 (when (re-search-backward php-heredoc-start-re nil t )
10291005 (let ((maybe (point )))
@@ -1107,8 +1083,7 @@ After setting the stylevars run hooks according to STYLENAME
11071083(defun php-mode--disable-delay-set-style (&rest args )
11081084 " Disable php-mode-set-style-delay on after hook. `ARGS' be ignore."
11091085 (setq php-mode--delayed-set-style nil )
1110- (when (fboundp 'advice-remove )
1111- (advice-remove #'php-mode--disable-delay-set-style #'c-set-style )))
1086+ (advice-remove #'php-mode--disable-delay-set-style #'c-set-style ))
11121087
11131088(defun php-mode-set-style-delay ()
11141089 " Set the current `php-mode' buffer to use the style by custom or local variables."
@@ -1196,8 +1171,7 @@ After setting the stylevars run hooks according to STYLENAME
11961171 (progn
11971172 (add-hook 'hack-local-variables-hook #'php-mode-set-style-delay t t )
11981173 (setq php-mode--delayed-set-style t )
1199- (when (fboundp 'advice-add )
1200- (advice-add #'c-set-style :after #'php-mode--disable-delay-set-style '(local))))
1174+ (advice-add #'c-set-style :after #'php-mode--disable-delay-set-style '(local)))
12011175 (let ((php-mode-enable-backup-style-variables nil ))
12021176 (php-set-style (symbol-name php-mode-coding-style))))
12031177
@@ -1230,6 +1204,7 @@ After setting the stylevars run hooks according to STYLENAME
12301204 (when (fboundp 'c-looking-at-or-maybe-in-bracelist )
12311205 (advice-add #'c-looking-at-or-maybe-in-bracelist
12321206 :override 'php-c-looking-at-or-maybe-in-bracelist ))
1207+ (advice-add #'fixup-whitespace :after #'php-mode--fixup-whitespace-after '(local))
12331208
12341209 (when (>= emacs-major-version 25 )
12351210 (with-silent-modifications
@@ -1504,7 +1479,7 @@ The output will appear in the buffer *PHP*."
15041479(defun php-string-intepolated-variable-font-lock-find (limit )
15051480 (while (re-search-forward php-string-interpolated-variable-regexp limit t )
15061481 (let ((quoted-stuff (nth 3 (syntax-ppss ))))
1507- (when (and quoted-stuff ( member quoted-stuff '( ?\" ?` ) ))
1482+ (when (or ( eq ?\" quoted-stuff) ( eq ?` quoted-stuff ))
15081483 (put-text-property (match-beginning 0 ) (match-end 0 )
15091484 'face 'php-variable-name ))))
15101485 nil )
@@ -1519,18 +1494,13 @@ The output will appear in the buffer *PHP*."
15191494
15201495; ;; Correct the behavior of `delete-indentation' by modifying the
15211496; ;; logic of `fixup-whitespace' .
1522- (defadvice fixup-whitespace (after php-mode-fixup-whitespace)
1497+ (defun php-mode-- fixup-whitespace-after ( )
15231498 " Remove whitespace before certain characters in PHP Mode."
1524- (let* ((no-behind-space " ;\\ |,\\ |->\\ |::" )
1525- (no-front-space " ->\\ |::" ))
1526- (when (and (eq major-mode 'php-mode )
1527- (or (looking-at-p (concat " \\ (" no-behind-space " \\ )" ))
1528- (save-excursion
1529- (forward-char -2 )
1530- (looking-at-p no-front-space))))
1531- (delete-char 1 ))))
1532-
1533- (ad-activate 'fixup-whitespace )
1499+ (when (or (looking-at-p " \\ (?:;\\ |,\\ |->\\ |::\\ )" )
1500+ (save-excursion
1501+ (forward-char -2 )
1502+ (looking-at-p " ->\\ |::" )))
1503+ (delete-char 1 )))
15341504
15351505;;;### autoload
15361506(progn
0 commit comments