[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#23827: 25.1.50; tab-width file-local variable has no effect in etc/H

From: Alan Mackenzie
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
User-agent: tin/2.3.1-20141224 ("Tallant") (UNIX) (FreeBSD/10.3-RELEASE-p4 (amd64))

Hello, Eli.

In article <address@hidden> you wrote:
> From: address@hidden
> --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 <address@hidden>
>   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

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 (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).

reply via email to

[Prev in Thread] Current Thread [Next in Thread]