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

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

[elpa] externals/nadvice 1bfa920 7/9: * nadvice/nadvice.el: Silence fewe


From: Stefan Monnier
Subject: [elpa] externals/nadvice 1bfa920 7/9: * nadvice/nadvice.el: Silence fewer errors
Date: Tue, 1 Dec 2020 16:29:05 -0500 (EST)

branch: externals/nadvice
commit 1bfa9201a8e3a13bb897e0d90c56ae40dd46d3b4
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>

    * nadvice/nadvice.el: Silence fewer errors
    
    (advice-member-p): New function.
    (advice-remove): Use it.
---
 nadvice.el | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/nadvice.el b/nadvice.el
index b4eec86..447132c 100644
--- a/nadvice.el
+++ b/nadvice.el
@@ -26,7 +26,7 @@
 ;; move to the new advice system without dropping support for Emacs<24.4.
 ;;
 ;; Limitations;
-;; - only supports `advice-add' and `advice-remove';
+;; - only supports `advice-add', `advice-remove', and `advice-member-p'.
 ;; - only handles the :before, :after, :override, and :around kinds of advice;
 ;; - requires a named rather than anonymous function;
 ;; - and does not support any additional properties like `name' or `depth'.
@@ -47,6 +47,9 @@
   ;; since ad-remove-advice is not autoloaded.
   (require 'advice)
 
+(defun advice-member-p (advice symbol)
+  (ad-find-advice symbol 'around advice))
+
 ;;;###autoload
 (defun advice-add (symbol where function &optional props)
   (when props
@@ -79,12 +82,9 @@
 (defun advice-remove (symbol function)
   ;; Just return nil if there is no advice, rather than signaling an
   ;; error.
-  (condition-case nil
-      (ad-remove-advice symbol 'around function)
-    (error nil))
-  (condition-case nil
-      (ad-activate symbol)
-    (error nil)))
+  (when (advice-member-p function symbol)
+    (ad-remove-advice symbol 'around function)
+    (ad-activate symbol)))
 
 )
 



reply via email to

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