From: Jesper Harder <harder@myrealbox.com>
Subject: Re: Canonical add-hook idiom
Date: Sat, 15 Nov 2003 17:55:25 +0100 [thread overview]
Message-ID: <m3n0axy3k2.fsf@defun.localdomain> (raw)
In-Reply-To: GWitb.1387$n56.744@newsread1.news.pas.earthlink.net
Bob Nelson <bnelson@nelsonbe.com> writes:
> What is the preferred approach given these examples:
>
> 1). (add-hook 'some-mode-hook (lambda () [...]
> 2). (add-hook 'some-mode-hook '(lambda () [...]
> 3). (add-hook 'some-mode-hook (function (lambda () [...]
> 4). None of the above -- please explain.
1) or 4).
It's sometimes better to avoid lambda and add a function instead.
This makes it easier to remove it from the hook again:
(add-hook 'foo-hook 'bar)
;; Oops, bar didn't work as expected:
(remove-hook 'foo-hook 'bar)
Removing isn't quite as easy for lambda's.
next prev parent reply other threads:[~2003-11-15 16:55 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-11-15 5:35 Canonical add-hook idiom Bob Nelson
2003-11-15 8:25 ` Oliver Scholz
2003-11-15 18:27 ` Henrik Enberg
2003-11-15 16:55 ` Jesper Harder [this message]
2003-11-16 23:26 ` Stefan Monnier
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=m3n0axy3k2.fsf@defun.localdomain \
--to=harder@myrealbox.com \
/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.
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).