summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2018-09-17 13:46:21 -0400
committerStefan Monnier <monnier@iro.umontreal.ca>2018-09-17 13:46:21 -0400
commit77c3c464a1603e2675347c88bb8cde26a6a3e2f8 (patch)
tree55f9bae82ac095d89a3fb06af545813ab17541dd /lisp/emacs-lisp
parent295bacba61bd681798b55599551116db197b3388 (diff)
downloademacs-77c3c464a1603e2675347c88bb8cde26a6a3e2f8.tar.gz
emacs-77c3c464a1603e2675347c88bb8cde26a6a3e2f8.tar.bz2
emacs-77c3c464a1603e2675347c88bb8cde26a6a3e2f8.zip
* lisp/emacs-lisp/advice.el (ad-advised-functions): Make it a plain list
(ad-read-advised-function, ad-do-advised-functions): Adjust accordingly. (ad-pushnew-advised-function, ad-pop-advised-function): Also make them into functions.
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r--lisp/emacs-lisp/advice.el21
1 files changed, 8 insertions, 13 deletions
diff --git a/lisp/emacs-lisp/advice.el b/lisp/emacs-lisp/advice.el
index 49c2d5f4f9f..6fb28c4c4d3 100644
--- a/lisp/emacs-lisp/advice.el
+++ b/lisp/emacs-lisp/advice.el
@@ -1575,7 +1575,6 @@
;; ==============================
(require 'macroexp)
-;; At run-time also, since ad-do-advised-functions returns code that uses it.
(eval-when-compile (require 'cl-lib))
;; @@ Variable definitions:
@@ -1662,18 +1661,14 @@ generates a copy of TREE."
;; (this list is maintained as a completion table):
(defvar ad-advised-functions nil)
-(defmacro ad-pushnew-advised-function (function)
+(defun ad-pushnew-advised-function (function)
"Add FUNCTION to `ad-advised-functions' unless its already there."
- `(if (not (assoc (symbol-name ,function) ad-advised-functions))
- (setq ad-advised-functions
- (cons (list (symbol-name ,function))
- ad-advised-functions))))
+ (add-to-list 'ad-advised-functions (symbol-name function)))
-(defmacro ad-pop-advised-function (function)
+(defun ad-pop-advised-function (function)
"Remove FUNCTION from `ad-advised-functions'."
- `(setq ad-advised-functions
- (delq (assoc (symbol-name ,function) ad-advised-functions)
- ad-advised-functions)))
+ (setq ad-advised-functions
+ (delete (symbol-name function) ad-advised-functions)))
(defmacro ad-do-advised-functions (varform &rest body)
"`dolist'-style iterator that maps over advised functions.
@@ -1683,7 +1678,7 @@ On each iteration VAR will be bound to the name of an advised function
\(a symbol)."
(declare (indent 1))
`(dolist (,(car varform) ad-advised-functions)
- (setq ,(car varform) (intern (car ,(car varform))))
+ (setq ,(car varform) (intern ,(car varform)))
,@body))
(defun ad-get-advice-info (function)
@@ -1849,7 +1844,7 @@ function at point for which PREDICATE returns non-nil)."
(require 'help)
(function-called-at-point))))
(and function
- (assoc (symbol-name function) ad-advised-functions)
+ (member (symbol-name function) ad-advised-functions)
(or (null predicate)
(funcall predicate function))
function))
@@ -2813,7 +2808,7 @@ advised definition from scratch."
;; advised definition will be generated.
(defun ad-preactivate-advice (function advice class position)
- "Preactivate FUNCTION and returns the constructed cache."
+ "Preactivate FUNCTION and return the constructed cache."
(let* ((advicefunname (ad-get-advice-info-field function 'advicefunname))
(old-advice (symbol-function advicefunname))
(old-advice-info (ad-copy-advice-info function))