Closed caadar closed 7 years ago
That behavior happens because when you define the patch, el-patch
uses fset
to install the function definition. Then, when you call helm-filtered-bookmarks
, it triggers an autoload to load helm-bookmark
, which evaluates the original defun
for helm-highlight-bookmark
. That overrides the patch.
The correct way to patch functions that are provided by an as-of-yet-unloaded feature is to wrap them in a with-eval-after-load
. See also el-patch-feature
, which allows you to validate such patches without previously loading the features.
The issue does not happen with advice because advice does lots of magic to allow for advising a function whose actual definition is not yet loaded. (Although for cleanliness, I still try to put my advices inside with-eval-after-load
forms.)
Ah, my missed (require 'helm-bookmark)
...
Thank you, will try with-eval-after-load
& el-patch-feature
mechanism also.
See example usage for el-patch-feature
: https://github.com/raxod502/radian/search?q=el-patch-feature
Great, all work pretty well!
Some time ago I modify
helm-highlight-bookmark
by el-patch and all was fine. Today I update Emacs packages including Helm and observe some nasty thing: this function work as before patching.What I see:
Restart Emacs, describe-function
helm-highlight-bookmark
=> "PATCHED!.." It seems OK, but wait...Eval (helm-filtered-bookmarks). It's my command of interest. It works unexpectedly though. Let's look at function again!
Describe-function
helm-highlight-bookmark
=> Oops, I see vanilla docstring only. Where is my patch?Eval following form by hand. Now patch really applied and all works fine.
After playing with various Emacs rc combo without success I return to old `advice-add' technics. It work as expected with the same configs.
So, Emacs Messages without errors, if form evaluated by hand it work, patch validation is OK also, another patched functions work fine. But loading this func at Emacs init is unsufficient. Mystique thing...