From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Lars Ingebrigtsen Newsgroups: gmane.emacs.bugs Subject: bug#15659: 24.1; (wishlist) Simple method for preserving minor-mode Date: Sat, 04 Dec 2021 04:37:13 +0100 Message-ID: <87y251qbva.fsf@gnus.org> References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24461"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: yary , 15659@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Dec 04 04:38:12 2021 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 1mtLsJ-00069N-HZ for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 04 Dec 2021 04:38:11 +0100 Original-Received: from localhost ([::1]:40754 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mtLsI-0002Fd-0C for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 03 Dec 2021 22:38:10 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:46626) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mtLs9-0002FG-Us for bug-gnu-emacs@gnu.org; Fri, 03 Dec 2021 22:38:01 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:41085) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mtLs9-0004bM-NM for bug-gnu-emacs@gnu.org; Fri, 03 Dec 2021 22:38:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mtLs9-0004vC-IZ for bug-gnu-emacs@gnu.org; Fri, 03 Dec 2021 22:38:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 04 Dec 2021 03:38:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 15659 X-GNU-PR-Package: emacs Original-Received: via spool by 15659-submit@debbugs.gnu.org id=B15659.163858904618862 (code B ref 15659); Sat, 04 Dec 2021 03:38:01 +0000 Original-Received: (at 15659) by debbugs.gnu.org; 4 Dec 2021 03:37:26 +0000 Original-Received: from localhost ([127.0.0.1]:52628 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mtLra-0004uA-0W for submit@debbugs.gnu.org; Fri, 03 Dec 2021 22:37:26 -0500 Original-Received: from quimby.gnus.org ([95.216.78.240]:59734) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mtLrY-0004tu-Dk for 15659@debbugs.gnu.org; Fri, 03 Dec 2021 22:37:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=dQknuNZxdK3GbcwfRv23/EnfbXoCjUHZymiiZN88kCY=; b=XI7OAD4fT1836oxtGaSsAuN/x+ hGP611hVq4145fSqrFpIi2Stpv0uUZ/eXai+mngANHpp3Llkm2mO4oiFTP1Sx5uBCQuIBxL7a1A4m ppeIrMYb2Ek+7VgRT1diIW0jucw7UDfCc+gXFr3kpcmjS43J02KEuDs9iqS1rg1QvdwI=; Original-Received: from [84.212.220.105] (helo=xo) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mtLrO-0001vq-0a; Sat, 04 Dec 2021 04:37:16 +0100 X-Now-Playing: Janis Joplin's _Pearl_: "Cry Baby" In-Reply-To: (Stefan Monnier's message of "Fri, 08 Nov 2013 15:29:20 -0500") 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:221427 Archived-At: Stefan Monnier writes: >> A function could take a minor-mode to preserve, and then either set up >> hooks needed to re-enable it after a major-mode change, or prevent >> `kill-all-local-variables' from disabling it in the first place. Or >> perhaps marking the minor-mode's function-symbol itself as >> `permanent-local' could protect it, along with all its buffer-locals. (I'm going through old bug reports that unfortunately weren't resolved at the time.) > We could start with something like the following (guaranteed 100% untested): > > (put 'after-change-major-mode-hook 'permanent-local-hook t) > > (defvar permanent-local--modes nil) > > (defun permanent-local--reenable () > (mapc #'funcall permanent-local--modes)) > (put 'permanent-local--reenable 'permanent-local-hook t) > > (defun permanent-local-mode (mode) > "Enable MODE permanently in this buffer." > (interactive > (list > (intern > (completing-read "Minor mode: " > obarray > (lambda (sym) > (or (memq mode minor-mode-list) > (string-match "-mode\\'" (symbol-name sym)))) > t)))) > (funcall mode) ;Enable. > (add-hook 'after-change-major-mode-hook #'permanent-local--reenable nil t)) I think this could work... but I don't really see it being used a lot. Changing a major mode is a relatively rare thing to do, and I don't see people using `permanent-local-mode' first -- because it'd be more work than just re-enabling the minor modes. And if you are in the habit of changing modes a lot (for instance, between two modes like cperl-mode and perl-mode), then I think you'd be more likely to want to put the minor modes into the major mode hooks. So, while it would be possible to add something like this, I just don't see the use case, so I don't think we should add this, and I'm closing this bug report. -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no