GNU bug report logs -
#15577
24.3; dir-local variables not applied when switching major-mode
Previous Next
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 #26 received at 15577 <at> debbugs.gnu.org (full text, mbox):
More thoughts, overturning my previous message of Oct 14th. I think I
have the essence of the issues now.
In my editing, I switch modes within a buffer (file) when working on:
A. databases- SQL inside code, or non-SQL language inside SQL triggers
B. web- HTML, CSS, JS is just the beginning...
C. any language with heredocs (shell, python, perl)- sometimes have
unrelated language blocks inside parent/wrapper code
and I've had these undesirable local-variable issues caused by that
mode switching:
1. dir-locals not being applied in the new mode
2. "manually" set local variables and minor-modes being lost.
Issue #1 "dir locals" is a narrow use case. Dir locals are not
intended to set a major mode; they are meant to set buffer-locals
after the major mode is in place. Whether set by a .dir-locals,el file
or dir-locals-set-* functions, the user is saying "buffers from files
here in this mode should have those variables set" and is saying so
clearly.
So, to fix that issue, after switching major modes, it would be good
to run "hack-dir-local-variables-non-file-buffer" to pick up any
dir-locals for the new mode.
Properly implementing that as an Emacs bug-fix is out of my skillset,
though the tips from stackoverflow helped me put a workaround in my
~/.emacs
Issue #2- "manually" set buffer-local's, and by extension file-local
variables- is trickier. Trying to automate what happens there smells
of unintended consequences. The answer here is an easier way for us to
set the "permanent-local-hook" property for variables (eg
"tab-width"), and minor-modes (eg "buffer-face-mode" with its new
face). Then I & others who use file-locals can mark a particular item
as "permanent" right in the file. Additionally, for other local
variables that people might want to keep (eg set interactively), have
an interactive command to mark a buffer-local variable or minor-mode
as permanent. And also, allow describe-variable, describe-minor-mode
to show/set the "permanent-local-hook" property.
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.