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: Thu, 05 Mar 2009 11:38:09 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.91 (gnu/linux)

> One of the reasons for using a lambda is to save having to think up a
> function name, and to save cluttering up one's .emacs, or whatever.
> Compare

>     (add-hook 'foo-mode-hook (lambda (some-minor-mode 1)))

> with

>     (defun switch-some-minor-mode-on ()
>       (some-minor-mode 1))
>     (add-hook 'foo-mode-hook 'switch-some-minor-mode-on)

FWIW, I use the second form in my .emacs, because I try to make my
.emacs idempotent (so I can just reload it any number of time, and that
won't add N copies of my lambda on that magic hook).


        Stefan





reply via email to

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