[Top][All Lists]

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

Re: Idempotency of add-hook wrt lambda expressions

From: David Kastrup
Subject: Re: Idempotency of add-hook wrt lambda expressions
Date: Thu, 05 Mar 2009 10:49:14 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

Geoff Gole <address@hidden> writes:

>> I'd much rather add a patch that complains when you pass a lambda to
> add-hook.
> Sounds good to me.

Does not jibe with existing practise.

For example, (info "(emacs) Init Examples") carefully explains

   * Turn on Auto Fill mode automatically in Text mode and related

          (add-hook 'text-mode-hook
            '(lambda () (auto-fill-mode 1)))

     This shows how to add a hook function to a normal hook variable
     (*note Hooks::).  The function we supply is a list starting with
     `lambda', with a single-quote in front of it to make it a list
     constant rather than an expression.

     It's beyond the scope of this manual to explain Lisp functions,
     but for this example it is enough to know that the effect is to
     execute `(auto-fill-mode 1)' when Text mode is entered.  You can
     replace that with any other expression that you like, or with
     several expressions in a row.

Sure, you can "fix" the manual here.  But you can't expect that the real
world has never used an idiom explicitly documented and used as an

Also, in some cases you can't avoid lambda, namely when using computed

David Kastrup

reply via email to

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