I'd like to temporarily override a function in a piece of code.
Take, for example, the following:
(defun nadvice/load-quiet (args) (cl-destructuring-bind (file &optional noerror nomessage nosuffix must-suffix) args (list file noerror t nosuffix must-suffix))) (defun nadvice/idle-require-quiet (old-fun &rest args) (advice-add 'load :filter-args #'nadvice/load-quiet) (apply old-fun args) (advice-remove #'load #'nadvice/load-quiet)) (advice-add 'idle-require-load-next :around #'nadvice/idle-require-quiet)
What doesn't work:
- This. It would be much cleaner if I could avoid manually enabling and disabling the advice and trust the single-threaded nature of Emacs to take care of things.
cl-letfwon't let me reference the origional function, so I can't implement things that
:filter-argswould normally do.
cl-fletcan't override functions in other functions.
nofletis an external package, which I'd like to avoid. (Also does much more than I need)