subj. Something like:
(lexical-let (oldf #'original-func)
(flet ((original-func (arg)
do-something
(funcall oldf arg)))
do-something))
don't work :(
subj. Something like:
(lexical-let (oldf #'original-func)
(flet ((original-func (arg)
do-something
(funcall oldf arg)))
do-something))
don't work :(
There is no reader macros in emacs-lisp, you need to use
symbol-function
explicitly.If you want to use it as a closure you'll need to use
lexical-let
instead oflet
or setlexical-binding
toT
.Hopefully this will help you with the syntax, calling swap-function calls foo1 but executes foo2.
You could write this as a useful macro with-replace-function which binds the old function with the new function while executing a body you pass in.