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

Previous Next

Package: emacs;

Reported by: yary <not.com <at> gmail.com>

Date: Sun, 20 Oct 2013 00:24:02 UTC

Severity: wishlist

Tags: wontfix

Found in version 24.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
Cc: yary <not.com <at> gmail.com>, 15659 <at> debbugs.gnu.org
Subject: bug#15659: 24.1; (wishlist) Simple method for preserving minor-mode
Date: Sat, 04 Dec 2021 04:37:13 +0100
Stefan Monnier <monnier <at> IRO.UMontreal.CA> 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




This bug report was last modified 3 years and 226 days ago.

Previous Next


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