emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/compat a7d9649 72/99: Manually advise functions when na


From: ELPA Syncer
Subject: [elpa] externals/compat a7d9649 72/99: Manually advise functions when nadvice is not available
Date: Sun, 17 Oct 2021 05:57:59 -0400 (EDT)

branch: externals/compat
commit a7d9649d369dc8a14aae2a08b3cd9875f3054a16
Author: Philip Kaludercic <philipk@posteo.net>
Commit: Philip Kaludercic <philipk@posteo.net>

    Manually advise functions when nadvice is not available
---
 compat-macs.el | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/compat-macs.el b/compat-macs.el
index 02609bc..6144eff 100644
--- a/compat-macs.el
+++ b/compat-macs.el
@@ -152,15 +152,17 @@ attributes (see `compat-generate-common')."
          ;; function.
          `(defalias ',name #',realname))
         ((eq type 'advice)
-         ;; nadvice.el was introduced in Emacs 24.4, so
-         ;; older versions have to use `defadvice'.
+         ;; nadvice.el was introduced in Emacs 24.4, so older versions
+         ;; have to manually advise the old function.
          (if (version<= "24.4" emacs-version)
              `(advice-add ',name :around #',realname)
-           `(ad-add-advice
-             ',name
-             (list ,(format "setup:%S" name)
-                   nil t (cons 'advice ,(lambda ()))
-                   'around 'first))))))
+           ;; FIXME consider using advice.el and `ad-add-advice'.
+           (let ((oldfun (make-symbol (format "oldfun-%S" name))))
+             `(progn
+                (defvar ,oldfun (indirect-function ',name))
+                (defalias ',name
+                  (lambda (&rest args)
+                    (apply #',realname (cons ,oldfun args))))))))))
      (lambda ()
        (cond
         ((memq type '(func macro))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]