From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Joost Kremers Newsgroups: gmane.emacs.help Subject: Re: Minor mode hook run when mode is deactivated? Date: Thu, 08 Oct 2020 08:44:30 +0200 Message-ID: <87h7r5b4j5.fsf@fastmail.fm> References: <87d01tr5l1.fsf@fastmail.fm> Mime-Version: 1.0 Content-Type: text/plain; format=flowed Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20793"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.5.5; emacs 27.1.50 Cc: help-gnu-emacs@gnu.org To: Stefan Monnier Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Thu Oct 08 08:45:12 2020 Return-path: Envelope-to: geh-help-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 1kQPfs-0005IW-0Q for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 08 Oct 2020 08:45:12 +0200 Original-Received: from localhost ([::1]:42552 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kQPfr-0002j9-2Y for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 08 Oct 2020 02:45:11 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50388) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kQPfR-0002ip-JU for help-gnu-emacs@gnu.org; Thu, 08 Oct 2020 02:44:46 -0400 Original-Received: from wout5-smtp.messagingengine.com ([64.147.123.21]:48247) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kQPfM-0000R9-HL for help-gnu-emacs@gnu.org; Thu, 08 Oct 2020 02:44:44 -0400 Original-Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id BF5021D0; Thu, 8 Oct 2020 02:44:34 -0400 (EDT) Original-Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Thu, 08 Oct 2020 02:44:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.fm; h= references:from:to:cc:subject:in-reply-to:date:message-id :mime-version:content-type; s=fm1; bh=fvom9gA++yaTHRppMBpxQz3KEN 7UqMlJgajz+cOfX+Y=; b=h3x5kG0QXzbs6rB4yAQkq7GCNPlSQU3JQxLDF5Il3H ec+wd4IMto9PxfG15sCksawt6IyTyzOcAVEMvq2Z1+YLESzJuxjKzIES3zhcyyaP S2W/z/7ryAUQfDSWcUaLLVf1T+VBkBvREORYcut7XTkhc75W5VzG1VJ3fuXYRrIP E6cJ1WOUYY9iG8tJpTbXiYYU/OvrYFajTMSd4Wpu5GKwO/iTjvnE/5GXGkWMgsQ9 TxvXcjsVCLYMFa9QlALy7vgcrnaIFsH/sDh3Q5Iuxqcfn++fRYrRvjjkhW+JEFgD 5v8F0M6Tf6d8BLroU1Iroo6lIob8TNZ+9ET6Ex7bzatQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=fvom9g A++yaTHRppMBpxQz3KEN7UqMlJgajz+cOfX+Y=; b=NnpyNhrdG+ERaZaKwxfLYY RT2IWH5kE6CosfjCGdITGxLhxcW9R3tl8VHT+PwZg75UBjBfQs64gGJwPcYGjYNj r8wy+3jQWzj9Iy/cqYquL8Uy2XKt8r/5QPjGpmhYR68/7E7tqmn9p3AGC08lW5z7 NG95gbBFvKd8GuLzt/vhMVs3++y1gsshYXwAsSuqU8VAC/XSq1xSwdDaj2FlpifG MxR0Q4Qz3dhUUPGR6McxEPo/usm6fty5/XAx8C+TUaXnwIB82EDWjb0yi12xdW8h R9qGZGRkXgF2TUEbGD3c0LUjguhZumo0B/MAhG6KsWSlgbP2Ia0FoUP+DsLv+rjQ == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrgeejgdduudduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfhgfhffvufgjfffkgggtsehttdertddtredtnecuhfhrohhmpeflohhoshht ucfmrhgvmhgvrhhsuceojhhoohhsthhkrhgvmhgvrhhssehfrghsthhmrghilhdrfhhmqe enucggtffrrghtthgvrhhnpeeluedtteejheelgfeigfelieetvddtueehgffgieeukeff vdffudfgudduueeffeenucffohhmrghinhepghhithhhuhgsrdgtohhmnecukfhppeelhe drledtrddvvdegrddvudegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehm rghilhhfrhhomhepjhhoohhsthhkrhgvmhgvrhhssehfrghsthhmrghilhdrfhhm X-ME-Proxy: Original-Received: from Swift.fastmail.com (ip5f5ae0d6.dynamic.kabel-deutschland.de [95.90.224.214]) by mail.messagingengine.com (Postfix) with ESMTPA id 870983064680; Thu, 8 Oct 2020 02:44:33 -0400 (EDT) In-reply-to: Received-SPF: pass client-ip=64.147.123.21; envelope-from=joostkremers@fastmail.fm; helo=wout5-smtp.messagingengine.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/08 02:44:35 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:124373 Archived-At: 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 if anyone's interested. -- Joost Kremers Life has its moments