help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Canonical add-hook idiom


From: Jesper Harder
Subject: Re: Canonical add-hook idiom
Date: Sat, 15 Nov 2003 17:55:25 +0100
User-agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3.50 (gnu/linux)

Bob Nelson <address@hidden> 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.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]