The following snippet, featuring the "fantasy function" clone-function
, illustrates what I'd like to do:
(defvar last-enabled-foo nil)
;; hold on to a "clone"/copy of third-party function enable-foo
(defvar original-enable-foo (clone-function 'enable-foo))
;; replace enable-foo with a wrapper function around it
;; module foo.el
(defun enable-foo (foo)
(setq last-enabled-foo foo)
(funcall original-enable-foo foo))
Basically, clone-function
ensures that original-enable-foo
refers to a function that is completely distinct from the newly defined enable-foo
.
How could one implement clone-function
?