remyhonig/elfeed-org

elfeed-org sets elfeed-new-entry-hook to nil

Closed this issue · 2 comments

Hello,

I was recently adding scoring to my elfeed configuration which requires adding a hook to elfeed-new-entry-hook. Every time I reloaded elfeed, this hook would disappear and the value of elfeed-new-entry-hook was reset to nil.

I tracked the issue down to line 211 in elfeed-org.el which is (setq elfeed-new-entry-hook nil)
Commenting out this line fixed the issue and did not introduce any other problems. I think this line could cause problems for anyone using elfeed-new-entry-hook in their setup

I was finally able to track this bug down to elfeed-org and found this bug. Been driving me crazy for a while, having to keep resetting my new-entry hooks!

I'm guessing the reason elfeed-org clears the hooks is so it doesn't create duplicates from its own hooks each time it's run. This is good, but deleting all of the user's hooks created outside of elfeed-org is not good. And such hooks must be supported because, since elfeed-org doesn't support all the kinds of entry taggers, it's not possible to put all kinds into one's elfeed-org config.

So how do we solve this? Well here are a few ideas I can think of:

  1. Support all tagger types in elfeed-org. Then a user could put all of his taggers in his elfeed-org config, and then elfeed-org could delete the new-entry hooks and recreate them all. This would be fairly straightforward I guess, but I'm not sure it's a good idea for two reasons: 1) Putting them in Org is not necessarily the most straightforward way to do it, compared to writing them in lisp. 2) elfeed-org then must keep up with any additions to elfeed in the future, or we get this bug again.

  2. Instead of setting elfeed-new-entry-hook to nil before adding hooks, elfeed-org could add its hooks and then delete duplicates from the list. This has the drawback that, if a user sets an entry-title tagger in elfeed, runs elfeed to load the hook, then changes that tagger and runs elfeed again, both the new and old entry hook will be present until elfeed-new-entry-hook is set to nil and the hooks are recreated.

  3. Instead of adding hooks directly to elfeed-new-entry-hook, elfeed-org could maintain its own list of its own tagger functions, like elfeed-org-new-entry-hook. Then it could add a single function to elfeed-new-entry-hook, like elfeed-org-run-new-entry-hooks, which would then run its own hooks when called. This way elfeed-org's taggers/hooks would be separate from the ones created outside of elfeed-org, and it could wipe and create them freely. This seems like the best solution.

What do you all think?

I made a PR that does what I suggested in #3 above. @ajsteven130 Please test it if you have a chance.