From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#43868: 27.1.50; Documentation: Mention that minor mode hooks are also run when the minor mode is deactivated Date: Thu, 08 Oct 2020 22:06:25 +0300 Message-ID: <83a6ww7d1q.fsf@gnu.org> References: <87sgao7dyd.fsf@fastmail.fm> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="7007"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 43868@debbugs.gnu.org To: Joost Kremers Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Oct 08 21:09:06 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kQbHl-0001kZ-T2 for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 08 Oct 2020 21:09:05 +0200 Original-Received: from localhost ([::1]:33758 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kQbHk-0000Ci-RY for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 08 Oct 2020 15:09:04 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48236) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kQbFn-0006If-Ib for bug-gnu-emacs@gnu.org; Thu, 08 Oct 2020 15:07:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:49869) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kQbFm-0004UJ-Lw for bug-gnu-emacs@gnu.org; Thu, 08 Oct 2020 15:07:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kQbFm-0007xf-Hq for bug-gnu-emacs@gnu.org; Thu, 08 Oct 2020 15:07:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 08 Oct 2020 19:07:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 43868 X-GNU-PR-Package: emacs Original-Received: via spool by 43868-submit@debbugs.gnu.org id=B43868.160218399730571 (code B ref 43868); Thu, 08 Oct 2020 19:07:02 +0000 Original-Received: (at 43868) by debbugs.gnu.org; 8 Oct 2020 19:06:37 +0000 Original-Received: from localhost ([127.0.0.1]:33182 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kQbFN-0007x0-BG for submit@debbugs.gnu.org; Thu, 08 Oct 2020 15:06:37 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:41292) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kQbFL-0007wo-LB for 43868@debbugs.gnu.org; Thu, 08 Oct 2020 15:06:36 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:41517) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kQbFG-0004RX-Eo; Thu, 08 Oct 2020 15:06:30 -0400 Original-Received: from [176.228.60.248] (port=1455 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kQbFF-00049G-E8; Thu, 08 Oct 2020 15:06:29 -0400 In-Reply-To: <87sgao7dyd.fsf@fastmail.fm> (message from Joost Kremers on Thu, 08 Oct 2020 20:46:50 +0200) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:190115 Archived-At: > From: Joost Kremers > Date: Thu, 08 Oct 2020 20:46:50 +0200 > > Minor mode hooks are run when the minor mode is activated but also when > the mode is deactivated. This is mentioned in the default doc string for minor > mode hooks, but it does not seem to be mentioned in the Elisp manual. > > I checked the section "Modes > Minor Modes > Defining Minor Modes", which > mentions that `define-minor-mode` creates a hook variable, but it doesn't > mention when it is run. I think it should be mentioned that it is run both when > the mode is activated and when the mode is deactivated. > > (Other sections don't seem to be as relevant: while searching for information on > this, I also looked in the section "Customization > Variables > Hooks", but that > section doesn't mention minor mode hooks at all. Same thing for the Emacs > manual: it doesn't seem to mention minor mode hooks anywhere.) "Minor Mode Conventions" In addition, several major mode conventions (*note Major Mode Conventions::) apply to minor modes as well: those regarding the names of global symbols, the use of a hook at the end of the initialization function, and the use of keymaps and other tables. "Major Mode Conventions": • Each major mode should have a normal “mode hook” named ‘MODENAME-mode-hook’. The very last thing the major mode command should do is to call ‘run-mode-hooks’. This runs the normal hook ‘change-major-mode-after-body-hook’, the mode hook, the function ‘hack-local-variables’ (when the buffer is visiting a file), and then the normal hook ‘after-change-major-mode-hook’. *Note Mode Hooks::. "Mode Hooks": Every major mode command should finish by running the mode-independent normal hook ‘change-major-mode-after-body-hook’, its mode hook, and the normal hook ‘after-change-major-mode-hook’. It does this by calling ‘run-mode-hooks’. Since the mode command runs both when turning the mode on and when turning it off, the above implies that the mode hook runs in both situations.