72
72
(require 'speedbar )
73
73
(require 'imenu )
74
74
(require 'package )
75
- (require 'nadvice nil t )
75
+ (require 'nadvice )
76
76
77
77
(require 'cl-lib )
78
78
(require 'mode-local )
85
85
(defvar c-vsemi-status-unknown-p )
86
86
(defvar syntax-propertize-via-font-lock ))
87
87
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
-
111
88
(autoload 'php-mode-debug " php-mode-debug"
112
89
" Display informations useful for debugging PHP Mode." t )
113
90
@@ -1022,8 +999,7 @@ this ^ lineup"
1022
999
; ; turn call this to be called again.
1023
1000
(push pair php-mode--propertize-extend-region-current)
1024
1001
(unwind-protect
1025
- (let ((new-start)
1026
- (new-end))
1002
+ (let (new-start new-end)
1027
1003
(goto-char start)
1028
1004
(when (re-search-backward php-heredoc-start-re nil t )
1029
1005
(let ((maybe (point )))
@@ -1107,8 +1083,7 @@ After setting the stylevars run hooks according to STYLENAME
1107
1083
(defun php-mode--disable-delay-set-style (&rest args )
1108
1084
" Disable php-mode-set-style-delay on after hook. `ARGS' be ignore."
1109
1085
(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 ))
1112
1087
1113
1088
(defun php-mode-set-style-delay ()
1114
1089
" 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
1196
1171
(progn
1197
1172
(add-hook 'hack-local-variables-hook #'php-mode-set-style-delay t t )
1198
1173
(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)))
1201
1175
(let ((php-mode-enable-backup-style-variables nil ))
1202
1176
(php-set-style (symbol-name php-mode-coding-style))))
1203
1177
@@ -1230,6 +1204,7 @@ After setting the stylevars run hooks according to STYLENAME
1230
1204
(when (fboundp 'c-looking-at-or-maybe-in-bracelist )
1231
1205
(advice-add #'c-looking-at-or-maybe-in-bracelist
1232
1206
:override 'php-c-looking-at-or-maybe-in-bracelist ))
1207
+ (advice-add #'fixup-whitespace :after #'php-mode--fixup-whitespace-after '(local))
1233
1208
1234
1209
(when (>= emacs-major-version 25 )
1235
1210
(with-silent-modifications
@@ -1504,7 +1479,7 @@ The output will appear in the buffer *PHP*."
1504
1479
(defun php-string-intepolated-variable-font-lock-find (limit )
1505
1480
(while (re-search-forward php-string-interpolated-variable-regexp limit t )
1506
1481
(let ((quoted-stuff (nth 3 (syntax-ppss ))))
1507
- (when (and quoted-stuff ( member quoted-stuff '( ?\" ?` ) ))
1482
+ (when (or ( eq ?\" quoted-stuff) ( eq ?` quoted-stuff ))
1508
1483
(put-text-property (match-beginning 0 ) (match-end 0 )
1509
1484
'face 'php-variable-name ))))
1510
1485
nil )
@@ -1519,18 +1494,13 @@ The output will appear in the buffer *PHP*."
1519
1494
1520
1495
; ;; Correct the behavior of `delete-indentation' by modifying the
1521
1496
; ;; logic of `fixup-whitespace' .
1522
- (defadvice fixup-whitespace (after php-mode-fixup-whitespace)
1497
+ (defun php-mode-- fixup-whitespace-after ( )
1523
1498
" 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 )))
1534
1504
1535
1505
;;;### autoload
1536
1506
(progn
0 commit comments