[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: question about "Making change-major-mode-hook buffer-local while loc
Re: question about "Making change-major-mode-hook buffer-local while locally let-bound!"
Tue, 22 Jun 2010 02:28:56 +0200
Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)
> (let ((emacs-lisp-mode-hook nil)
> (change-major-mode-hook nil))
> What is the right way to prevent these hooks from running here?
(let ((emacs-lisp-mode-hook nil)
> Do I need to use remove-hook followed by add-hook: saving, emptying and
> repopulating the hook? What's the right approach?
Those hooks are not permanent-local, so they'll be emptied and
repopulated as needed by the call to emacs-lisp-mode.
So you could probably just do:
(set (make-local-variable 'emacs-lisp-mode-hook) nil)
(set (make-local-variable 'change-major-mode-hook) nil)
Or use `remove-hook' to eliminate only the particular values which are
undesired rather than removing them all.
> Why bother? What is gained by having such a runtime message?
This messages is linked to a problematic circumstance where Emacs tries
to do its best, but where the code should ideally be changed to avoid
such a circumstance. So it's important to detect and warn about those
cases, and sadly, I don't know how to do it at a better time.