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: Stefan Monnier
Subject: Re: Minor mode hook run when mode is deactivated?
Date: Wed, 07 Oct 2020 19:45:17 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

> I recently ran into a problem that was apparently caused by a minor mode
> hook being run when the mode is deactivated. Counter-intuitive as that may
> be (to me, at least), a quick look at the code for `define-minor-mode` seems
> to suggest that it's in fact correct.

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.


        Stefan




reply via email to

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