Created
April 24, 2015 09:43
-
-
Save mpontus/b6d848559ddb450ffd37 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmacro ecukes-recurse-catch (symbols &rest body) | |
"Catch on entry to SYMBOLS during execution of BODY." | |
(letrec ((value (make-symbol "thrown-value")) | |
(function (lambda () (throw value nil))) | |
(fnsym (make-symbol "advice")) (unwind)) | |
`(let ((,fnsym ,function)) | |
,@(mapcar (lambda (symbol) | |
(prog1 `(advice-add ',symbol :override ,fnsym) | |
(push `(remove-advice ',symbol ,fnsym) unwind))) | |
(if (listp symbols) symbols (list symbols))) | |
(unwind-protect (catch ,value ,@body) ,unwind)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment