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: Alan Mackenzie
Subject: Re: Idempotency of add-hook wrt lambda expressions
Date: Thu, 5 Mar 2009 16:45:32 +0000
User-agent: Mutt/1.5.9i

On Thu, Mar 05, 2009 at 08:53:23PM +0900, Geoff Gole wrote:
> > Also, in some cases you can't avoid lambda, namely when using computed
> > functions.

> Can't you avoid this with (add-hook 'hook (progn (fset symbol
> calculated-definition) symbol)) or similar?

Probably, yes.  But who'd want to?

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)

.

-- 
Alan Mackenzie (Nuremberg, Germany).




reply via email to

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