Skip to content

Commit 65b8db5

Browse files
monnierzonuexe
authored andcommitted
Fixed incorrect use of 'local' (nonexistent) advice
1 parent e515cc9 commit 65b8db5

File tree

1 file changed

+21
-20
lines changed

1 file changed

+21
-20
lines changed

lisp/php-mode.el

+21-20
Original file line numberDiff line numberDiff line change
@@ -660,13 +660,14 @@ but only if the setting is enabled."
660660
'+)
661661
(t nil)))))))
662662

663-
(defun php-c-looking-at-or-maybe-in-bracelist (&optional _containing-sexp lim)
663+
(defun php-c-looking-at-or-maybe-in-bracelist (orig-fun &optional containing-sexp lim)
664664
"Replace `c-looking-at-or-maybe-in-bracelist'.
665665
666666
CONTAINING-SEXP is the position of the brace/paren/bracket enclosing
667667
POINT, or nil if there is no such position, or we do not know it. LIM is
668668
a backward search limit."
669669
(cond
670+
((not (derived-mode-p 'php-mode)) (apply orig-fun containing-sexp lim args))
670671
((looking-at-p "{")
671672
(save-excursion
672673
(c-backward-token-2 2 t lim)
@@ -1208,7 +1209,7 @@ After setting the stylevars run hook `php-mode-STYLENAME-hook'."
12081209
(progn
12091210
(add-hook 'hack-local-variables-hook #'php-mode-set-style-delay t t)
12101211
(setq php-mode--delayed-set-style t)
1211-
(advice-add #'c-set-style :after #'php-mode--disable-delay-set-style '(local)))
1212+
(advice-add 'c-set-style :after #'php-mode--disable-delay-set-style))
12121213
(let ((php-mode-enable-backup-style-variables nil))
12131214
(php-set-style (symbol-name php-mode-coding-style))))
12141215

@@ -1242,15 +1243,12 @@ After setting the stylevars run hook `php-mode-STYLENAME-hook'."
12421243
php-mode-replace-flymake-diag-function)
12431244
(add-hook 'flymake-diagnostic-functions php-mode-replace-flymake-diag-function nil t))
12441245

1245-
(when (fboundp 'c-looking-at-or-maybe-in-bracelist)
1246-
(advice-add #'c-looking-at-or-maybe-in-bracelist
1247-
:override 'php-c-looking-at-or-maybe-in-bracelist '(local)))
1248-
(advice-add #'fixup-whitespace :after #'php-mode--fixup-whitespace-after '(local))
1246+
(advice-add 'c-looking-at-or-maybe-in-bracelist
1247+
:around 'php-c-looking-at-or-maybe-in-bracelist)
1248+
(advice-add 'fixup-whitespace :after #'php-mode--fixup-whitespace-after)
12491249

1250-
(when (fboundp #'acm-backend-tabnine-candidate-expand)
1251-
(advice-add #'acm-backend-tabnine-candidate-expand
1252-
:filter-args #'php-acm-backend-tabnine-candidate-expand-filter-args
1253-
'(local)))
1250+
(advice-add 'acm-backend-tabnine-candidate-expand
1251+
:filter-args #'php-acm-backend-tabnine-candidate-expand-filter-args)
12541252

12551253
(when (>= emacs-major-version 25)
12561254
(with-silent-modifications
@@ -1558,22 +1556,25 @@ The output will appear in the buffer *PHP*."
15581556
;;; logic of `fixup-whitespace'.
15591557
(defun php-mode--fixup-whitespace-after ()
15601558
"Remove whitespace before certain characters in PHP Mode."
1561-
(when (or (looking-at-p " \\(?:;\\|,\\|->\\|::\\)")
1562-
(save-excursion
1563-
(forward-char -2)
1564-
(looking-at-p "->\\|::")))
1559+
(when (and (derived-mode-p 'php-mode)
1560+
(or (looking-at-p " \\(?:;\\|,\\|->\\|::\\)")
1561+
(save-excursion
1562+
(forward-char -2)
1563+
(looking-at-p "->\\|::"))))
15651564
(delete-char 1)))
15661565

15671566
;; Advice for lsp-bridge' acm-backend-tabnine
15681567
;; see https://github.com/manateelazycat/lsp-bridge/issues/402#issuecomment-1305653058
15691568
(defun php-acm-backend-tabnine-candidate-expand-filter-args (args)
15701569
"Adjust to replace bound-start ARGS for Tabnine in PHP."
1571-
(cl-multiple-value-bind (candidate-info bound-start) args
1572-
(save-excursion
1573-
(goto-char bound-start)
1574-
(when (looking-at-p (eval-when-compile (regexp-quote "$")))
1575-
(setq bound-start (1+ bound-start))))
1576-
(list candidate-info bound-start)))
1570+
(if (not (derived-mode-p 'php-mode))
1571+
args
1572+
(cl-multiple-value-bind (candidate-info bound-start) args
1573+
(save-excursion
1574+
(goto-char bound-start)
1575+
(when (looking-at-p (eval-when-compile (regexp-quote "$")))
1576+
(setq bound-start (1+ bound-start))))
1577+
(list candidate-info bound-start))))
15771578

15781579
;;;###autoload
15791580
(progn

0 commit comments

Comments
 (0)