Add let-advice!! test macro

This commit is contained in:
Henrik Lissner 2018-01-03 14:10:31 -05:00
parent f1268b130f
commit b7d21fb256
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -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))))