[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master a4a58da: * nadvice/nadvice.el: Silence fewer errors
From: |
Stefan Monnier |
Subject: |
[elpa] master a4a58da: * nadvice/nadvice.el: Silence fewer errors |
Date: |
Mon, 17 Sep 2018 10:07:34 -0400 (EDT) |
branch: master
commit a4a58da154a1475cec7a73fce9934e1be19deabd
Author: Stefan Monnier <address@hidden>
Commit: Stefan Monnier <address@hidden>
* nadvice/nadvice.el: Silence fewer errors
(advice-member-p): New function.
(advice-remove): Use it.
---
packages/nadvice/nadvice.el | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/packages/nadvice/nadvice.el b/packages/nadvice/nadvice.el
index b4eec86..447132c 100644
--- a/packages/nadvice/nadvice.el
+++ b/packages/nadvice/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)))
)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] master a4a58da: * nadvice/nadvice.el: Silence fewer errors,
Stefan Monnier <=