Subject: Re: 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: Sat, 28 Jan 2012 21:24:15 +0100

On Sat, 28 Jan 2012 11:37:12 +0100
Chong Yidong wrote:

> Štěpán Němec <[email-masked]> writes:
>
>> emacs -Q
>>
>> (defvar f-m-hook-run 0)
>>
>> (add-hook 'fundamental-mode-hook
>>           (lambda () (setq f-m-hook-run (1+ f-m-hook-run))))
>>
>> (with-current-buffer (get-buffer-create "f-m-test-buf")
>>   major-mode)
>> ;=> fundamental-mode
>>
>> f-m-hook-run
>> ;=> 0
>>
>> (with-current-buffer (get-buffer-create "f-m-test-buf")
>>   (fundamental-mode)
>>   major-mode)
>> ;=> fundamental-mode
>>
>> f-m-hook-run
>> ;=> 1
>
> This was fixed a few months ago (2011-10-27 commit to simple.el).
> Closing the bug.  Thanks.

Well, with current emacs-snapshot (GNU Emacs 24.0.92.1
(i486-pc-linux-gnu, GTK+ Version 3.2.3) of 2012-01-26 on zelenka,
modified by Debian) I get `0' even for the second time above. So now
`fundamental-mode-hook' doesn't seem to be run at all? That fixes the
documentation problem I guess, but is certainly not what I need.

What's the point of having `fundamental-mode-hook' at all, if it isn't
ever run?

And, how can I run code whenever a new buffer is setup (in
fundamental-mode), if `fundamental-mode-hook' is not meant for that?

-- 
Štěpán