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

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

[elpa] externals/compat 80ab781 77/99: Use advice.el for advising functi


From: ELPA Syncer
Subject: [elpa] externals/compat 80ab781 77/99: Use advice.el for advising functions previously to Emacs 24.4
Date: Sun, 17 Oct 2021 05:58:00 -0400 (EDT)

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

    Use advice.el for advising functions previously to Emacs 24.4
---
 compat-macs.el | 14 +++++++-------
 compat.el      |  5 +----
 2 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/compat-macs.el b/compat-macs.el
index 7cf0e24..a554b70 100644
--- a/compat-macs.el
+++ b/compat-macs.el
@@ -157,14 +157,14 @@ attributes (see `compat-generate-common')."
          (if (version<= "24.4" emacs-version)
              `(advice-add ',name :around #',realname)
            ;; FIXME consider using advice.el and `ad-add-advice'.
-           (let ((oldfun (make-symbol (format "oldfun-%S" name))))
+           (let ((oldfun (make-symbol (format "compat--oldfun-%S" realname))))
              `(progn
-                (defvar ,oldfun (indirect-function ',name))
-                (defalias ',name
-                  (lambda (&rest args)
-                    ,(format "[Compatibility advice using `%s']\n\n%s"
-                             realname (documentation name))
-                    (apply #',realname (cons ,oldfun args))))))))))
+                (defvar ,oldfun (indirect-function ,name))
+                (put ',name 'compat-advice-fn #',realname)
+                (defadvice ,name (around
+                                  ,(intern (format "ad--%S" realname))
+                                  (&rest args) activate)
+                  (apply #',realname (cons oldfun args)))))))))
      (lambda ()
        (cond
         ((memq type '(func macro))
diff --git a/compat.el b/compat.el
index 6039df3..d150b86 100644
--- a/compat.el
+++ b/compat.el
@@ -70,11 +70,8 @@ advice."
    ((and handle-advice
          (featurep 'advice)
          ;; See `ad-advice-p'
-         (ad-is-advised func)
          (ad-is-active func))
-    (let* ((adv (symbol-function
-                 (ad-get-advice-info-field
-                  func 'advicefunname)))
+    (let* ((adv (get func 'compat-advice-fn))
            (arity (compat-func-arity adv)))
       (cons (1- (car arity))
             (if (numberp (cdr arity))



reply via email to

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