From: Stefan Monnier <monnier@iro.umontreal.ca>
To: "Drew Adams" <drew.adams@oracle.com>
Cc: emacs-devel@gnu.org
Subject: Re: question about "Making change-major-mode-hook buffer-local while locally let-bound!"
Date: Tue, 22 Jun 2010 02:28:56 +0200 [thread overview]
Message-ID: <jwvzkync3w8.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <B12C1F29818444CA9A46648514F19CA2@us.oracle.com> (Drew Adams's message of "Sun, 20 Jun 2010 09:51:33 -0700")
> (let ((emacs-lisp-mode-hook nil)
> (change-major-mode-hook nil))
> (emacs-lisp-mode))
[...]
> What is the right way to prevent these hooks from running here?
E.g.:
(make-local-variable 'emacs-lisp-mode-hook)
(make-local-variable 'change-major-mode-hook)
(let ((emacs-lisp-mode-hook nil)
(change-major-mode-hook nil))
(emacs-lisp-mode))
> 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)
(emacs-lisp-mode)
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.
Stefan
next prev parent reply other threads:[~2010-06-22 0:28 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-20 16:51 question about "Making change-major-mode-hook buffer-local while locally let-bound!" Drew Adams
2010-06-20 18:31 ` question about "Making change-major-mode-hook buffer-local whilelocally let-bound!" Drew Adams
2010-06-20 20:56 ` Davis Herring
2010-06-20 21:24 ` Drew Adams
2010-06-20 23:15 ` question about "Making change-major-mode-hook buffer-local while locally let-bound!" Johan Bockgård
2010-06-20 23:29 ` question about "Making change-major-mode-hook buffer-localwhile " Drew Adams
2010-06-22 0:28 ` Stefan Monnier [this message]
2010-06-22 4:10 ` question about "Making change-major-mode-hook buffer-local while " Drew Adams
2010-06-22 5:01 ` Davis Herring
2010-06-22 5:44 ` Drew Adams
-- strict thread matches above, loose matches on Subject: below --
2010-06-20 20:38 MON KEY
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jwvzkync3w8.fsf-monnier+emacs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=drew.adams@oracle.com \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).