emacs-devel
[Top][All Lists]
Advanced

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

Re: Idempotency of add-hook wrt lambda expressions


From: Stefan Monnier
Subject: Re: Idempotency of add-hook wrt lambda expressions
Date: Wed, 04 Mar 2009 09:18:12 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.91 (gnu/linux)

> Say a file contains an add-hook form with a lambda argument:
>   (add-hook 'foo-mode (lambda () (bar)))
> Annoyingly, the function will be added to the hook twice if the file
> is byte compiled, loaded, then reevaluated (such as with eval-buffer).

As a general rule, you should not put a lambda but a function name
(i.e. a symbol) instead, to avoid all those problems (and be able to
replace the function with a newer version of it).  But occasionally
a lambda is really exactly what you want, of course.


        Stefan





reply via email to

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