Skip to content

Commit 9a91e48

Browse files
committed
Use advice-add instead of defadvice
1 parent 38bbf39 commit 9a91e48

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

lisp/php-mode.el

+7-11
Original file line numberDiff line numberDiff line change
@@ -1204,6 +1204,7 @@ After setting the stylevars run hooks according to STYLENAME
12041204
(when (fboundp 'c-looking-at-or-maybe-in-bracelist)
12051205
(advice-add #'c-looking-at-or-maybe-in-bracelist
12061206
:override 'php-c-looking-at-or-maybe-in-bracelist))
1207+
(advice-add #'fixup-whitespace :after #'php-mode--fixup-whitespace-after '(local))
12071208

12081209
(when (>= emacs-major-version 25)
12091210
(with-silent-modifications
@@ -1493,18 +1494,13 @@ The output will appear in the buffer *PHP*."
14931494

14941495
;;; Correct the behavior of `delete-indentation' by modifying the
14951496
;;; logic of `fixup-whitespace'.
1496-
(defadvice fixup-whitespace (after php-mode-fixup-whitespace)
1497+
(defun php-mode--fixup-whitespace-after ()
14971498
"Remove whitespace before certain characters in PHP Mode."
1498-
(let* ((no-behind-space ";\\|,\\|->\\|::")
1499-
(no-front-space "->\\|::"))
1500-
(when (and (eq major-mode 'php-mode)
1501-
(or (looking-at-p (concat " \\(" no-behind-space "\\)"))
1502-
(save-excursion
1503-
(forward-char -2)
1504-
(looking-at-p no-front-space))))
1505-
(delete-char 1))))
1506-
1507-
(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)))
15081504

15091505
;;;###autoload
15101506
(progn

0 commit comments

Comments
 (0)