[emacs-berlin] Understanding hooks

jman emacs-berlin at city17.xyz
Wed Sep 18 17:39:05 UTC 2024


Michael Heerdegen <michael_heerdegen at web.de> writes:

> Using only local hooks would be cumbersome if what
> you want is more "having a blacklist" like.  Using a global hook
> variable doesn't let you deactivate the thing for certain cases,

Oh, this is the critical key information I was missing. I was running in
circles, both `describe-function` and info pages looked a bit ambiguous
about whether one can use `remove-hook` to override locally a global
hook. Now I understand that I can't. I find it slightly confusing, I
expected remove-hook to mirror add-hook. Anyway, it is what it
is. That's good context to know.

> Note that Emacs also uses a lot of buffer saving in the background
> (custom files, desktop files, bookmarks, files created by your Emacs
> mail program, ...).  Most of the time the "white list" approach is
> less full of surprises.

Even Doom Emacs doesn't use whitespace-clean because too invasive. I'll
take your suggestion and replace whitespace-mode in favour of a less
invasive ws-butler which promises to acts only on lines that I
change.

If that doesn't work either (I've already opened an issue[0]), I'll
change approach and write a little wrapper to run the cleaning skipping
some major modes, like you suggest.

> Ok - that was a long answer.  Please tell about your chosen solution!
> Or do you need further advice?

Thank you so much for your help and patience explaining these basics :-)

(also many thanks to user "bitspook" for suggesting some very useful
explaination about how `remove-hook` works!)

Best,

[0]: https://github.com/lewang/ws-butler/issues/50


More information about the emacs-berlin mailing list