GNU bug report logs - #15577
24.3; dir-local variables not applied when switching major-mode

Previous Next

Package: emacs;

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

Date: Wed, 9 Oct 2013 20:15:01 UTC

Severity: normal

Merged with 23407

Found in version 24.3

Done: Alan Mackenzie <acm <at> muc.de>

Bug is archived. No further changes may be made.

Full log


Message #29 received at 15577 <at> debbugs.gnu.org (full text, mbox):

From: yary <not.com <at> gmail.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: Glenn Morris <rgm <at> gnu.org>, 15577 <15577 <at> debbugs.gnu.org>
Subject: Re: bug#15577: 24.3;
 dir-local variables not applied when switching major-mode
Date: Fri, 18 Oct 2013 11:43:54 -0400
My implementation thoughts for core-level fixes, after working on
personal workarounds.

For sub-issue #1 "dir-locals not being applied in the new mode,"
divide the responsibility for setting file-locals and dir-locals
between `normal-mode find-file=t' and `define-derived-mode'. Just have
`define-derived-mode' call
`(hack-dir-local-variables)(hack-local-variables-apply)' unless it is
being called as a result of `normal-mode t'. There's no change needed
for the normal-mode function or anything it calls, except perhaps
setting something that the define-derived-mode macro can check.


For sub-issue #2 "an easier way for us to preserve minor-modes and
buffer-local variables when switching modes"- I discovered this
exchange showing it's been raised before
https://lists.gnu.org/archive/html/emacs-devel/2007-12/msg00366.html
which resulted in adding the property `permanent-local-hook' to
compliment the `permanent-local' property, facilitating minor-mode
preservation. That was in the context of helping mode authors preserve
specific minor-modes. In itself, it isn't enough for a generic
minor-mode preservation but it can help.

A function to preserve any minor-mode needs to

a. Get all of that mode's customizable buffer-locals. Ideally the
minor-mode, or emacs core, would provide a function for that purpose.
If not, might be able to reliably get a list by creating a scratch
buffer, saving results of `buffer-local-variables', enabling the minor
mode in question, then mark the differences from a subsequent call to
`buffer-local-variables'.
b. Mark those variables as permanent-local

Then either

b1. Continue to allow major-mode changes to disable all minor-modes,
but re-enable the user-requested minor-modes after calling
kill-all-local-variables. This doesn't require any use of
`permanent-local-hook'; the minor mode is being disabled and
re-enabled and any hooks can be normally uninstalled & re-installed &
re-run

b2. Apply `permanent-local-hook' to all the minor-mode's hook
functions. The minor mode might provide those symbols via a function
for that purpose, or perhaps they could be auto-discovered.

Alas I don't yet know enough about Emacs' minor-mode handling to get
further with these thoughts. Thanks for bearing with me.

-y




This bug report was last modified 9 years and 13 days ago.

Previous Next


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