unofficial mirror of bug-gnu-emacs@gnu.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: Fri, 18 Oct 2013 11:43:54 -0400	[thread overview]
Message-ID: <CAG2CFAY1k+kgqD_kdwp5GchofY+1ZZe=U8AnxtgtXi4JViGP5g@mail.gmail.com> (raw)
In-Reply-To: <CAG2CFAbF7qFO6+M3QJ_BhPurBOoYnysKOO8Gnkf-qCg0MhCOxw@mail.gmail.com>

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





  reply	other threads:[~2013-10-18 15:43 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
2013-10-18 15:43               ` yary [this message]
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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to='CAG2CFAY1k+kgqD_kdwp5GchofY+1ZZe=U8AnxtgtXi4JViGP5g@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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).