|
From: | Glenn Morris |
Subject: | bug#22348: 24.5; Mode hooks doesn't run as expected if the major mode of a new buffer is determined by the default major mode |
Date: | Mon, 11 Jan 2016 17:27:10 -0500 |
User-agent: | Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/) |
Gosh, that's rather a long bug report. :) If you do: ./src/emacs -Q --eval "(progn (setq-default major-mode 'text-mode) (add-hook 'text-mode-hook (lambda () (message \"FOO\") (sit-for 3))))" /tmp/foo.bar you'll see it works fine. This suggest that the issue is specific to point-motion (your example used end-of-buffer). set-auto-mode calls set-buffer-major-mode if nothing else specifies a mode. set-buffer-major-mode can operate on buffers other than the current one, and uses save-excursion to preserve buffer. But set-auto-mode calls it to operate on current-buffer. Thus save-excursion undoes your hook's point changes. So that's the real issue here.
[Prev in Thread] | Current Thread | [Next in Thread] |