all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: yary <not.com@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 15577 <15577@debbugs.gnu.org>
Subject: bug#15577: 24.3; dir-local variables not applied when switching major-mode
Date: Wed, 16 Oct 2013 10:26:14 -0400	[thread overview]
Message-ID: <CAG2CFAbF7qFO6+M3QJ_BhPurBOoYnysKOO8Gnkf-qCg0MhCOxw@mail.gmail.com> (raw)
In-Reply-To: <CAG2CFAYTycdF2gzs-XgpvafB3gNEwCvJ_yM2MyUo_V2DqTAEXQ@mail.gmail.com>

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.





  reply	other threads:[~2013-10-16 14:26 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-09 20:14 bug#15577: 24.3; dir-local variables not applied when switching major-mode yary
2013-10-09 21:42 ` Glenn Morris
2013-10-10 18:34   ` yary
2013-10-10 21:27     ` Glenn Morris
2013-10-10 21:52       ` Stefan Monnier
2013-10-10 23:12         ` yary
2013-10-14 18:41           ` yary
2013-10-16 14:26             ` yary [this message]
2013-10-18 15:43               ` yary
2013-10-19  1:18                 ` Stefan Monnier
2013-10-19 19:08                   ` yary
2013-10-19 21:55                     ` Stefan Monnier
2013-10-20 13:00                       ` yary
2013-10-20 13:38                         ` Phil Sainty
2013-10-21 13:11                           ` Stefan Monnier
2013-10-21 13:23                             ` yary
2013-10-21 14:23                               ` Stefan Monnier
2013-10-21 21:58                                 ` Phil Sainty
2013-10-18 16:29               ` Phil Sainty
     [not found] ` <mailman.3789.1381430919.10748.bug-gnu-emacs@gnu.org>
2016-05-05 11:26   ` Alan Mackenzie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAG2CFAbF7qFO6+M3QJ_BhPurBOoYnysKOO8Gnkf-qCg0MhCOxw@mail.gmail.com \
    --to=not.com@gmail.com \
    --cc=15577@debbugs.gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.