Subject: bug#9214: `fundamental-mode-hook' not run when setting up `fundamental-mode' under certain circumstances; Info documentation incorrect

From: Štěpán Němec <[email-masked]>
Date: Sun, 29 Jan 2012 17:34:27 +0100

On Sun, 29 Jan 2012 02:44:27 +0100
Juanma Barranquero wrote:

> On Sun, Jan 29, 2012 at 02:40, Chong Yidong <[email-masked]> wrote:
>
>> Or use after-change-major-mode-hook.
>
> The OP's use case
>
> (with-current-buffer (get-buffer-create "f-m-test-buf")
>  major-mode)
>
> does not run after-change-major-mode-hook, I think.

Exactly. I need a way to run code for _any_ new buffer (I don't really
need to run the code for temporary buffers which never get any user
interaction, but I don't think there is a way to set those apart), no
matter how it is created.

Is that really so much to ask?

If so, I suppose a `display-buffer-functions' hook as proposed by Juanma
on emacs-devel just now[1] would be something I could make do with (the
problem with that solution would be that I only need to run the code
once when the buffer is created, but I guess testing a variable every
time a buffer is displayed isn't worse than running useless code for
never-displayed temporary buffers).

`after-change-major-mode-hook' is what I use, but it is not run for new
default-moded buffers, even when I setq-default `major-mode' to
something else than `fundamental-mode' (maybe because `major-mode' is
only used when the buffer is created by `find-file'? The `major-mode'
docstring needs some clarification in that respect).

[1] <http://permalink.gmane.org/gmane.emacs.devel/147999>

-- 
Štěpán