Add undefadvice! macro for rotate-text convenience

This commit is contained in:
Henrik Lissner 2020-01-01 14:31:49 -05:00
parent 7a348f8784
commit 5929e5b75a
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
2 changed files with 19 additions and 0 deletions

View file

@ -424,5 +424,23 @@ DOCSTRING and BODY are as in `defun'.
(dolist (target (cdr targets)) (dolist (target (cdr targets))
(advice-add target (car targets) #',symbol)))))) (advice-add target (car targets) #',symbol))))))
(defmacro undefadvice! (symbol _arglist &optional docstring &rest body)
"Undefine an advice called SYMBOL.
This has the same signature as `defadvice!' an exists as an easy undefiner when
testing advice (when combined with `rotate-text').
\(fn SYMBOL ARGLIST &optional DOCSTRING &rest [WHERE PLACES...] BODY\)"
(declare (doc-string 3) (indent defun))
(let (where-alist)
(unless (stringp docstring)
(push docstring body))
(while (keywordp (car body))
(push `(cons ,(pop body) (doom-enlist ,(pop body)))
where-alist))
`(dolist (targets (list ,@(nreverse where-alist)))
(dolist (target (cdr targets))
(advice-remove target #',symbol)))))
(provide 'core-lib) (provide 'core-lib)
;;; core-lib.el ends here ;;; core-lib.el ends here

View file

@ -31,6 +31,7 @@ This marks a foldable marker for `outline-minor-mode' in elisp buffers.")
("let" "let*") ("let" "let*")
("when" "unless") ("when" "unless")
("advice-add" "advice-remove") ("advice-add" "advice-remove")
("defadvice!" "undefadvice!")
("add-hook" "remove-hook") ("add-hook" "remove-hook")
("add-hook!" "remove-hook!") ("add-hook!" "remove-hook!")
("it" "xit") ("it" "xit")