all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: help-gnu-emacs@gnu.org
Subject: Re: Minor mode hook run when mode is deactivated?
Date: Wed, 07 Oct 2020 19:45:17 -0400	[thread overview]
Message-ID: <jwvtuv5pprc.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: 87d01tr5l1.fsf@fastmail.fm

> 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	other threads:[~2020-10-07 23:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-07 23:15 Minor mode hook run when mode is deactivated? Joost Kremers
2020-10-07 23:45 ` Stefan Monnier [this message]
2020-10-08  6:44   ` Joost Kremers
2020-10-08 13:53     ` Stefan Monnier
2020-10-08 14:33       ` Joost Kremers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvtuv5pprc.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.