help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Hook doesn't run as expected, if buffer mode is set from major-mode


From: Rolf Ade
Subject: Re: Hook doesn't run as expected, if buffer mode is set from major-mode
Date: Sat, 09 Jan 2016 01:15:56 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

Drew Adams <address@hidden> writes:

>> If the major mode of a new buffer is determined by the variable
>> major-mode (nothing from auto-mode-alist et. al matches), then the hooks
>> of that major mode doesn't run, as I expect.
>
> `major-mode' is a buffer-local variable.
> It is set by the newly current major mode.
> IOW, you cannot use it to set the mode, as the mode sets it.

So, what do you think determines the major-mode of a new buffer, if (as
I wrote) nothing from auto-mode-alist, interpreter-mode-alist and
magic-mode-alist matches? What should I use for that (if I don't want
the default fundamental-mode)?

It is right, that major-mode is a buffer-local variable. And it is also
true, that it is set by the newly current major-mode. But what value
does the local variable major-mode have, if there isn't a major-mode,
for a new buffer? Right, its default value. And this is a way to set the
major mode of a new buffer, if there isn't another known from other
sources.

Take a look at C-h v major-mode RET. (And, maybe, C-h v
default-major-mode RET).


reply via email to

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