If I get the function definition with
(setq wrapped-copy (symbol-function 'fn))
how can I make a copy such that I can redefine the same function with a wrapped version? like
(fset 'fn #'(lambda () (wrapped-copy)))
I tried with copy-seq
but I think it copies by reference, so the anon function looses the function definition in the wrapped copy
fset
lets you define an alias, likedefalias
does. And you're using a variable whose value is a function in function position. Elisp is a Lisp 2, not a Lisp 1, so you would need(lambda () (funcall wrapped-copy))
. But as I say, to me it's not clear what you're asking.