You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When patching a function, I think it might be better (from an Emacs compatibility point of view) to define an advice with :override instead of over-defining the function.
I realize this would only work with functions, and not with other types (?), but since functions are the most patched type this might be worth it.
At the very least, something like this could be suitable
(defmacroel-patch-function (func-name &rest args)
"Patches function FUNC-NAME.Similar to `el-patch-defun' except the patch is applied as an`:override' advice."
(let* ((patch-name (make-symbol
(concat (symbol-name func-name) "@el-patch")))
(new-args (cl-list* 'defun `(el-patch-swap ,func-name ,patch-name)
args)))
`(progn
(el-patch--definition ,new-args)
(advice-add (quote,func-name) :override (quote,patch-name))
',patch-name)))
(and a similarly defined el-patch-define-function-template).
The text was updated successfully, but these errors were encountered:
We would still have to keep the old system for patching other definition types, so I'm not sure this would be a simplification. It also wouldn't work for the lazy-loading use case. Is there a particular limitation to the current implementation which you think would be alleviated by using advice instead?
There’s no limitation to the current implementation that I can think of. It’s more about using the standard Emacs way of patching (and unpatching), in the spirit of writing packages that prefer built-in features (like selectrum vs ivy).
When patching a function, I think it might be better (from an Emacs compatibility point of view) to define an advice with
:override
instead of over-defining the function.I realize this would only work with functions, and not with other types (?), but since functions are the most patched type this might be worth it.
At the very least, something like this could be suitable
(and a similarly defined
el-patch-define-function-template
).The text was updated successfully, but these errors were encountered: