I'm exploring options for monkey-patching and I'm wondering if the following is within reason.
I would like to override a particular function within some target function so that calls within the target function are overridden, but functions called directly by the target function are unaffected. Whether the overridden function inherits the override isn't particularly important.
(require 'noflet) (defun my-message (msg) (message (concat "**" msg "**"))) (defun unaffected-fn () (my-message "Goodbye!")) (defun target-fn () (my-message "Hello!") (unaffected-fn)) (noflet ((my-message (msg) (message (concat "@@" msg "@@")))) (target-fn))
The output of this code is:
I would like to avoid
unaffected-fn inheriting this local override. The output for the desired behavior would be:
Suggestions for clearer wording of this question are welcome.