From b7d21fb25636b0473850968fcdc62422e9fe8eb2 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Wed, 3 Jan 2018 14:10:31 -0500 Subject: [PATCH] Add let-advice!! test macro --- core/autoload/test.el | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/core/autoload/test.el b/core/autoload/test.el index e41cd424c..dd2ea3796 100644 --- a/core/autoload/test.el +++ b/core/autoload/test.el @@ -159,8 +159,21 @@ marker. e.g. {2} can be retrieved with (point!! 2)." marker-list))) (defmacro with-minor-mode!! (mode &rest body) - "TODO" + "Activate a minor mode while in BODY, deactivating it after." (declare (indent defun)) `(progn (,mode +1) ,@body (,mode -1))) + +(defmacro let-advice!! (binds &rest body) + "Temporarily bind advice in BINDS while in BODY. + +e.g. (old-fn :before advice-fn) + (old-fn :around advice-fn)" + (declare (indent defun)) + `(progn + ,@(cl-loop for (target type advice) in binds + collect `(advice-add #',target ,type #',advice)) + ,@body + ,@(cl-loop for (target type advice) in binds + collect `(advice-remove #',target #',advice))))