all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: 23827@debbugs.gnu.org
Subject: bug#23827: 25.1.50; tab-width file-local variable has no effect in etc/HELLO
Date: 24 Jun 2016 11:07:13 -0000	[thread overview]
Message-ID: <20160624110713.13909.qmail@mail.muc.de> (raw)
In-Reply-To: <mailman.2018.1466615229.1216.bug-gnu-emacs@gnu.org>

Hello, Eli.

In article <mailman.2018.1466615229.1216.bug-gnu-emacs@gnu.org> you wrote:
> From: eliz@HOME-C4E4A596F7.i-did-not-set--mail-host-address--so-tickle-me
> --text follows this line--
> To reproduce:

>   emacs -Q
>   C-h H

> Observe the messed-up alignment of the second column.  The reason is
> that the tab-width file-local variable setting didn't take effect;
> setting the variable by hand fixes the display.

> I suspect this change:

>   commit 26171e02773b9b2383f412dd79d241385d2d20df
>   Author: Alan Mackenzie <acm@muc.de>
>   Date:   Fri May 6 18:58:49 2016 +0000

>       Correct hack-local-variables change from Thu May 5 11:05:49 2016 +0000

>       Prevent hack-local-variables being called from the fundamental-mode mode call
>       early in normal-mode.  This fixes bug #23460 and bug #23463.

>       * lisp/files.el (normal-mode) Replace call to fundamental-mode with calls to
>       the things it calls, with the exception of hack-local-variables.

>       * etc/NEWS: Add an entry to note the calling of hack-local-variables at each
>       major mode initialization.

Yes.  That change (and the change it corrected) shifted the call of
`hack-local-variables' from the act of visiting a file, to the calling of
the major mode function.  Every major mode (including fundamental-mode)
calls `run-mode-hooks' which calls `hack-local-variables'.

However, the C function `set-buffer-major-mode', optimises the call to
`fundamental-mode' away, because that call previously didn't do anything.

(`set-buffer-major-mode' is the last fallback function which choses the
major mode when all other methods have been tried and failed in
`set-auto-mode'.)

So I propose to remove that special optimisation from
`set-buffer-major-mode', so that `fundamental-mode' actually gets called.
As an alternative, it would be possible to add special handling at the
Lisp level for `fundamental-mode', but I think that would be a worse fix.

Here's my proposed patch, which works:


diff --git a/src/buffer.c b/src/buffer.c
index b4b8304..8756cbb 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -1984,7 +1984,9 @@ the current buffer's major mode.  */)
 	function = BVAR (current_buffer, major_mode);
     }
 
-  if (NILP (function) || EQ (function, Qfundamental_mode))
+  if (NILP (function)) /* If function is `fundamental-mode', allow it to run
+                          so that `run-mode-hooks' and thus
+                          `hack-local-variables' get run. */
     return Qnil;
 
   count = SPECPDL_INDEX ();


What do you think?


> In GNU Emacs 25.1.50.166 (i686-pc-mingw32)
>  of 2016-06-22 built on HOME-C4E4A596F7
> Repository revision: cc113e557d56d849e9699ceb3bc4a735c628b46e
> Windowing system distributor 'Microsoft Corp.', version 5.1.2600
> Recent messages:
> For information about GNU Emacs and the GNU system, type C-h C-a.

[ .... ]

-- 
Alan Mackenzie (Nuremberg, Germany).






  parent reply	other threads:[~2016-06-24 11:07 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-22 17:05 bug#23827: 25.1.50; tab-width file-local variable has no effect in etc/HELLO Eli Zaretskii
     [not found] ` <mailman.2018.1466615229.1216.bug-gnu-emacs@gnu.org>
2016-06-24 11:07   ` Alan Mackenzie [this message]
2016-06-24 13:28     ` Eli Zaretskii
2016-06-24 14:12       ` Stefan Monnier
2016-06-24 14:17         ` Eli Zaretskii
2016-06-24 14:27           ` Stefan Monnier
2016-06-24 16:09             ` Alan Mackenzie
2016-06-25  0:21               ` Stefan Monnier
2016-06-27 12:52                 ` Alan Mackenzie
2016-06-27 22:03                   ` Stefan Monnier
2016-06-28 10:10                     ` Alan Mackenzie
2016-06-28 21:43                       ` Stefan Monnier
2016-06-30  9:22                         ` Alan Mackenzie
2016-06-30 22:37                           ` Stefan Monnier
2016-06-30 22:39                           ` Stefan Monnier
2016-10-10 10:37                             ` Eli Zaretskii
2016-10-15 14:07                               ` Eli Zaretskii
2016-06-24 16:35 ` Leo Liu
     [not found] ` <mailman.2101.1466786228.1216.bug-gnu-emacs@gnu.org>
2016-06-24 17:17   ` 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=20160624110713.13909.qmail@mail.muc.de \
    --to=acm@muc.de \
    --cc=23827@debbugs.gnu.org \
    /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.