GNU bug report logs - #15659
24.1; (wishlist) Simple method for preserving minor-mode

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Severity: wishlist; Reported by: yary <not.com@HIDDEN>; Keywords: wontfix; Done: Lars Ingebrigtsen <larsi@HIDDEN>; Maintainer for emacs is bug-gnu-emacs@HIDDEN.
bug closed, send any further explanations to 15659 <at> debbugs.gnu.org and yary <not.com@HIDDEN> Request was from Lars Ingebrigtsen <larsi@HIDDEN> to control <at> debbugs.gnu.org. Full text available.
Added tag(s) wontfix. Request was from Lars Ingebrigtsen <larsi@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 15659 <at> debbugs.gnu.org:


Received: (at 15659) by debbugs.gnu.org; 4 Dec 2021 03:37:26 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Dec 03 22:37:26 2021
Received: from localhost ([127.0.0.1]:52628 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1mtLra-0004uA-0W
	for submit <at> debbugs.gnu.org; Fri, 03 Dec 2021 22:37:26 -0500
Received: from quimby.gnus.org ([95.216.78.240]:59734)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <larsi@HIDDEN>) id 1mtLrY-0004tu-Dk
 for 15659 <at> 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=;
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 <larsi@HIDDEN>)
 id 1mtLrO-0001vq-0a; Sat, 04 Dec 2021 04:37:16 +0100
From: Lars Ingebrigtsen <larsi@HIDDEN>
To: Stefan Monnier <monnier@HIDDEN>
Subject: Re: bug#15659: 24.1; (wishlist) Simple method for preserving
 minor-mode
References: <CAG2CFAavwPpLqwG2Yt-itZs5AzUN_5o-f+3084zxEaHA3_6EZA@HIDDEN>
 <jwv7gcibq83.fsf-monnier+emacsbugs@HIDDEN>
X-Now-Playing: Janis Joplin's _Pearl_: "Cry Baby"
Date: Sat, 04 Dec 2021 04:37:13 +0100
In-Reply-To: <jwv7gcibq83.fsf-monnier+emacsbugs@HIDDEN> (Stefan Monnier's
 message of "Fri, 08 Nov 2013 15:29:20 -0500")
Message-ID: <87y251qbva.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 @@CONTACT_ADDRESS@@ for details.
 Content preview: Stefan Monnier <monnier@HIDDEN> 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 f [...] 
 Content analysis details:   (-2.9 points, 5.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -1.0 ALL_TRUSTED            Passed through trusted hosts only via SMTP
 -1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%
 [score: 0.0000]
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 15659
Cc: yary <not.com@HIDDEN>, 15659 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Stefan Monnier <monnier@HIDDEN> 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




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#15659; Package emacs. Full text available.
Removed tag(s) wontfix. Request was from Lars Ingebrigtsen <larsi@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 15659 <at> debbugs.gnu.org:


Received: (at 15659) by debbugs.gnu.org; 8 Nov 2013 20:29:25 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Nov 08 15:29:24 2013
Received: from localhost ([127.0.0.1]:42316 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1VesgG-0006Rj-G4
	for submit <at> debbugs.gnu.org; Fri, 08 Nov 2013 15:29:24 -0500
Received: from chene.dit.umontreal.ca ([132.204.246.20]:54818)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <monnier@HIDDEN>) id 1VesgE-0006Rb-9f
 for 15659 <at> debbugs.gnu.org; Fri, 08 Nov 2013 15:29:22 -0500
Received: from faina.iro.umontreal.ca (lechon.iro.umontreal.ca
 [132.204.27.242])
 by chene.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id rA8KTLlb015100;
 Fri, 8 Nov 2013 15:29:21 -0500
Received: by faina.iro.umontreal.ca (Postfix, from userid 20848)
 id 08DEFB4327; Fri,  8 Nov 2013 15:29:20 -0500 (EST)
From: Stefan Monnier <monnier@HIDDEN>
To: yary <not.com@HIDDEN>
Subject: Re: bug#15659: 24.1;
 (wishlist) Simple method for preserving minor-mode
Message-ID: <jwv7gcibq83.fsf-monnier+emacsbugs@HIDDEN>
References: <CAG2CFAavwPpLqwG2Yt-itZs5AzUN_5o-f+3084zxEaHA3_6EZA@HIDDEN>
Date: Fri, 08 Nov 2013 15:29:20 -0500
In-Reply-To: <CAG2CFAavwPpLqwG2Yt-itZs5AzUN_5o-f+3084zxEaHA3_6EZA@HIDDEN>
 (yary's message of "Sat, 19 Oct 2013 20:22:33 -0400")
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-NAI-Spam-Flag: NO
X-NAI-Spam-Threshold: 5
X-NAI-Spam-Score: 0
X-NAI-Spam-Rules: 1 Rules triggered
	RV4756=0
X-NAI-Spam-Version: 2.3.0.9362 : core <4756> : inlines <209> : streams
 <1070306> : uri <1589554>
X-Spam-Score: -1.3 (-)
X-Debbugs-Envelope-To: 15659
Cc: 15659 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.3 (-)

> 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.

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))


-- Stefan




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#15659; Package emacs. Full text available.
Added tag(s) wontfix. Request was from Pádraig Brady <P@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 15659 <at> debbugs.gnu.org:


Received: (at 15659) by debbugs.gnu.org; 20 Oct 2013 13:27:15 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Oct 20 09:27:15 2013
Received: from localhost ([127.0.0.1]:58826 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1VXt2I-0001TT-4l
	for submit <at> debbugs.gnu.org; Sun, 20 Oct 2013 09:27:14 -0400
Received: from mail-wg0-f45.google.com ([74.125.82.45]:58255)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <not.com@HIDDEN>) id 1VXt2D-0001TB-S3
 for 15659 <at> debbugs.gnu.org; Sun, 20 Oct 2013 09:27:11 -0400
Received: by mail-wg0-f45.google.com with SMTP id z12so5456629wgg.0
 for <15659 <at> debbugs.gnu.org>; Sun, 20 Oct 2013 06:27:04 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
 h=mime-version:in-reply-to:references:from:date:message-id:subject:to
 :cc:content-type;
 bh=SDpa5C74oEeIvJaLeBNKzEAOnj9jqhnZxzem0Rd9Lak=;
 b=Z8sHFCL0Ecamjjk4gggJZ0yg6alTg2upERPKp3BBULKtrpsAV9dMomcv4T8Uar8Yub
 hee0vu8Pcya14SDd0Hm/QGf2TTS61Niyt041egek4Yah77YAt1VfDMeZ874ZCddI7DII
 uRez0iBnooO7PcZFLwoJlvvg15lt+8Bxb59kcY61HVRtaMdrMkhZXUCeMymGUB9fhO8b
 VNy16oheKVUP2LRGZsOywOiWCQQdH4/ZEkLuDbdyzepyykt8naEk/weYxspn8wKet+Ma
 Bp2Sj1Gr6RAZp75HKmpEuJm3zkdu+FkMBmyRaq7O2CRnq4WSztk9maOjwH1kiO4agwcK
 fcng==
X-Received: by 10.194.201.225 with SMTP id kd1mr1342591wjc.35.1382275624082;
 Sun, 20 Oct 2013 06:27:04 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.194.83.72 with HTTP; Sun, 20 Oct 2013 06:26:44 -0700 (PDT)
In-Reply-To: <jwv38nwafrl.fsf-monnier+emacsbugs@HIDDEN>
References: <CAG2CFAavwPpLqwG2Yt-itZs5AzUN_5o-f+3084zxEaHA3_6EZA@HIDDEN>
 <jwv38nwafrl.fsf-monnier+emacsbugs@HIDDEN>
From: yary <not.com@HIDDEN>
Date: Sun, 20 Oct 2013 09:26:44 -0400
Message-ID: <CAG2CFAbCgsbrkA=Zpn33v0ADVK2bWW7mna1vMaOm_BqHV+hKsQ@HIDDEN>
Subject: Re: bug#15659: 24.1;
 (wishlist) Simple method for preserving minor-mode
To: Stefan Monnier <monnier@HIDDEN>
Content-Type: text/plain; charset=ISO-8859-1
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 15659
Cc: 15659 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

On Sat, Oct 19, 2013 at 9:33 PM, Stefan Monnier
<monnier@HIDDEN> wrote:
>> There are times when I wish to set a minor-mode permanently for a
>> buffer, even through major-mode changes. They are display-related
>> minor-modes, such as buffer-face-mode or text-scale-mode.
>
> Indeed, those two should probably be make "permanent local".

That's a better solution than prompting people to make permanent those
minor-modes themselves, via some new generic method for preserving any
minor mode.

I can still see a reason to have something like a `:local-variables'
keyword for any mode definition, minor or major- to help `desktop
save/recover' properly handle the buffer state. Doubtless there would
be yet more uses I haven't thought of.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#15659; Package emacs. Full text available.

Message received at 15659 <at> debbugs.gnu.org:


Received: (at 15659) by debbugs.gnu.org; 20 Oct 2013 01:33:24 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Oct 19 21:33:23 2013
Received: from localhost ([127.0.0.1]:58415 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1VXhtT-0007YE-8d
	for submit <at> debbugs.gnu.org; Sat, 19 Oct 2013 21:33:23 -0400
Received: from ironport2-out.teksavvy.com ([206.248.154.182]:23551)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <monnier@HIDDEN>) id 1VXhtR-0007Xw-3y
 for 15659 <at> debbugs.gnu.org; Sat, 19 Oct 2013 21:33:21 -0400
X-IronPort-Anti-Spam-Filtered: true
X-IronPort-Anti-Spam-Result: Av4EABK/CFFFxLCX/2dsb2JhbABEvw4Xc4IeAQEEAVYjBQsLNBIUGA0kiB4GwS2RCgOkeoFegxM
X-IPAS-Result: Av4EABK/CFFFxLCX/2dsb2JhbABEvw4Xc4IeAQEEAVYjBQsLNBIUGA0kiB4GwS2RCgOkeoFegxM
X-IronPort-AV: E=Sophos;i="4.84,565,1355115600"; d="scan'208";a="35895303"
Received: from 69-196-176-151.dsl.teksavvy.com (HELO pastel.home)
 ([69.196.176.151])
 by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA;
 19 Oct 2013 21:33:15 -0400
Received: by pastel.home (Postfix, from userid 20848)
 id CBBA960475; Sat, 19 Oct 2013 21:33:14 -0400 (EDT)
From: Stefan Monnier <monnier@HIDDEN>
To: yary <not.com@HIDDEN>
Subject: Re: bug#15659: 24.1;
 (wishlist) Simple method for preserving minor-mode
Message-ID: <jwv38nwafrl.fsf-monnier+emacsbugs@HIDDEN>
References: <CAG2CFAavwPpLqwG2Yt-itZs5AzUN_5o-f+3084zxEaHA3_6EZA@HIDDEN>
Date: Sat, 19 Oct 2013 21:33:14 -0400
In-Reply-To: <CAG2CFAavwPpLqwG2Yt-itZs5AzUN_5o-f+3084zxEaHA3_6EZA@HIDDEN>
 (yary's message of "Sat, 19 Oct 2013 20:22:33 -0400")
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.3 (/)
X-Debbugs-Envelope-To: 15659
Cc: 15659 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 0.3 (/)

> There are times when I wish to set a minor-mode permanently for a
> buffer, even through major-mode changes. They are display-related
> minor-modes, such as buffer-face-mode or text-scale-mode.

Indeed, those two should probably be make "permanent local".


        Stefan




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#15659; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 20 Oct 2013 00:23:11 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Oct 19 20:23:11 2013
Received: from localhost ([127.0.0.1]:58383 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1VXgnW-0005je-5p
	for submit <at> debbugs.gnu.org; Sat, 19 Oct 2013 20:23:10 -0400
Received: from eggs.gnu.org ([208.118.235.92]:49034)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <not.com@HIDDEN>) id 1VXgnQ-0005iz-SD
 for submit <at> debbugs.gnu.org; Sat, 19 Oct 2013 20:23:05 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <not.com@HIDDEN>) id 1VXgnK-00010C-5c
 for submit <at> debbugs.gnu.org; Sat, 19 Oct 2013 20:22:59 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM,
 T_DKIM_INVALID autolearn=disabled version=3.3.2
Received: from lists.gnu.org ([2001:4830:134:3::11]:56718)
 by eggs.gnu.org with esmtp (Exim 4.71)
 (envelope-from <not.com@HIDDEN>) id 1VXgnK-000106-1V
 for submit <at> debbugs.gnu.org; Sat, 19 Oct 2013 20:22:58 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:50751)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <not.com@HIDDEN>) id 1VXgnI-0005Ac-IL
 for bug-gnu-emacs@HIDDEN; Sat, 19 Oct 2013 20:22:57 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <not.com@HIDDEN>) id 1VXgnG-0000zd-J0
 for bug-gnu-emacs@HIDDEN; Sat, 19 Oct 2013 20:22:56 -0400
Received: from mail-wg0-x22e.google.com ([2a00:1450:400c:c00::22e]:41278)
 by eggs.gnu.org with esmtp (Exim 4.71)
 (envelope-from <not.com@HIDDEN>) id 1VXgnG-0000zY-Bw
 for bug-gnu-emacs@HIDDEN; Sat, 19 Oct 2013 20:22:54 -0400
Received: by mail-wg0-f46.google.com with SMTP id m15so5089316wgh.1
 for <bug-gnu-emacs@HIDDEN>; Sat, 19 Oct 2013 17:22:53 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
 h=mime-version:from:date:message-id:subject:to:content-type;
 bh=h3A75cXs7UKnmeJFyQbM4kr7bqV0uAIyMIPBVB1Z2Bk=;
 b=VjtjDFE+6jWN8JHAQKGl+wA3Ejc/WseU+efHz36R029p4cdyFPzlpw9WGMTcFsv983
 u9xCs7YUVWw6ZA8SWl/bulEkzLvjAbjWFH/VC24u/PurLWFTwQhNwoaPj/pKrzoVBgWq
 bxNCe7v5PC+iJGHQH8sbhcTxu7OTjtEoJl/RHNQExpfHx/sGUSGFSp5+X3dWMtBfrPM/
 3gkNwC5PIU2m3FAJk6ewE5ZZSeKOfYsvy6tRR9Ippa9HqkuqXXnV64RWgMTWv7m+zzUu
 3PsafJlGtUbfGsVbtGXerygJjFVWAqbrwTb0zqiocfdGToWePYXX2fM3KtJP52B8fFMw
 njbw==
X-Received: by 10.194.222.2 with SMTP id qi2mr8128290wjc.14.1382228573470;
 Sat, 19 Oct 2013 17:22:53 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.194.83.72 with HTTP; Sat, 19 Oct 2013 17:22:33 -0700 (PDT)
From: yary <not.com@HIDDEN>
Date: Sat, 19 Oct 2013 20:22:33 -0400
Message-ID: <CAG2CFAavwPpLqwG2Yt-itZs5AzUN_5o-f+3084zxEaHA3_6EZA@HIDDEN>
Subject: 24.1; (wishlist) Simple method for preserving minor-mode
To: bug-gnu-emacs@HIDDEN
Content-Type: text/plain; charset=ISO-8859-1
X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address
 (bad octet value).
X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address
 (bad octet value).
X-Received-From: 2001:4830:134:3::11
X-Spam-Score: -4.0 (----)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -4.0 (----)

There are times when I wish to set a minor-mode permanently for a
buffer, even through major-mode changes. They are display-related
minor-modes, such as buffer-face-mode or text-scale-mode.

Ideally I'd like a simple way to preserve a minor-mode between
major-mode changes. I started discussing this in Bug #15577, which is
about dir-locals, but am moving it here as this is a separate issue.

Also bug #15396 "permanent-local truncate-lines" is related, Stefan sets
a display-related local variable and would like it preserved across mode
changes (or in this case, revert-buffer). Yet setting `permanent-local'
on the `truncate-lines' variable does not protect it:
`toggle-truncate-lines' behaves like a minor mode.

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 have a personal workaround which works for modes I use posted at
http://stackoverflow.com/a/19439236/379333 - though it isn't fully
generalized and has other flaws. It checks if specified minor-modes
are active during `change-major-mode-hook', and if so, then tries to
figure out which variables they use, and then restores those variables
and minor modes in the `after-change-major-mode-hook'

Answering a question from bug #15577 about this issue:

>> a. Get all of that mode's customizable buffer-locals.
>
>Not sure what that is.

The modes I wanted to preserve have buffer-locals for the face, and
for the size adjustment. It's not enough to just re-enable the modes,
we have to know which buffer-locals the mode reads.

>> Ideally the minor-mode, or emacs core, would provide a function for
>> that purpose.
>
>It's probably not possible (not reliably at least) with the way minor
>modes are defined currently.  Tho depending on what you mean it might be
>a non-issue.

What I meant was, since any proposed minor-mode-preserving mechanism
needs to know what buffer-local variables also would need to be set
`permanent-local', then "Ideally the minor-mode, or emacs core, would
provide a function" listing those variables. So for example, the
`define-minor-mode' macro might get a `:local-variables' keyword
allowing the author to declare that mode's buffer-locals, along with
their documentation and defaults. Would not be required in general,
but would make it easier for anything that wants to manipulate minor
modes.

>> b. Mark those variables as permanent-local
>
>There's no such thing, currently (we instead have to use a hack with
>change-major-mode-hook, along the lines of what you did).

Must be a mis-communication here. The docs to `kill-all-local-variables' say:

  As a special exception, local variables whose names have
  a non-nil `permanent-local' property are not eliminated by this function.

I just tried (put 'foo 'permanent-local 't) and `foo' survived
`kill-all-local-variables' and several mode changes. So we do have the
`permanent-local' property for keeping local variables around.

>But there are some issues:
>- we have to find out which buffer-local minor-modes are enabled, which
>  presumes we have some kind of list of minor-modes.  We can probably
>  use minor-mode-list for that, tho.

Searching minor-mode-list would work, as would checking that the
symbol "name-of-minor-mide' is buffer-local and has a non-nil value.

>- some minor modes are mode-specific; e.g. it doesn't make much sense to
>  preserve reftex-mode when switching from latex-mode to haskell-mode.

This sounds like another mis-communication- proposal is to let a user
(or by extension a minor-mode-author) to easily mark a minor-mode as
"to-be-preserved." As another example, I do not want flymake still on
when switching into css-mode. It's not up to this method to decide
which minor-modes to preserve; it is up to the user.

-y




Acknowledgement sent to yary <not.com@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#15659; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Sat, 4 Dec 2021 03:45:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.