help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Minor mode hook run when mode is deactivated?


From: Joost Kremers
Subject: Re: Minor mode hook run when mode is deactivated?
Date: Thu, 08 Oct 2020 08:44:30 +0200
User-agent: mu4e 1.5.5; emacs 27.1.50


On Thu, Oct 08 2020, Stefan Monnier wrote:
If you need to do something when a minor mode is activated, you most
likely also need to do something to "undo" it when the mode
is deactivated.  So, yes, the minor mode hooks are run both when
activating and when deactivating, and they should check the value of the
minor mode variable to know which it is.

That makes sense, but it does mean that you cannot put a minor mode onto another minor mode hook.[1]

Which is OK, I was just surprised that I wasn't able to find anything about this in the documentation. Is in there and I just didn't search well enough, or should it perhaps be added?

Joost


Footnotes:
[1] That was my scenario. I have a minor mode that I wrote and to which I added an extra hook that's run when the mode is deactivated. I thought this would allow me to turn off other minor modes that I had activated in my minor mode's hook, but it wasn't working. Turns out the minor mode hook is also run when the mode is deactivated, after my additional deactivate-hook was run... Details here <https://github.com/joostkremers/writeroom-mode/issues/63> if anyone's interested.



--
Joost Kremers
Life has its moments



reply via email to

[Prev in Thread] Current Thread [Next in Thread]