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

From: Eli Zaretskii <[email-masked]>
Date: Fri, 24 Jun 2016 16:28:52 +0300

> Date: 24 Jun 2016 11:07:13 -0000
> From: Alan Mackenzie <[email-masked]>
> Cc: Eli Zaretskii <[email-masked]>
> 
> 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?

LGTM, but I'm not an expert on modes.  I'd like to hear opinions from
others.  Stefan?

Thanks.