From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Kastrup Newsgroups: gmane.emacs.devel Subject: Re: Idempotency of add-hook wrt lambda expressions Date: Thu, 05 Mar 2009 10:49:14 +0100 Message-ID: <861vtcxpt1.fsf@lola.quinscape.zz> References: <74F2CF19-2E71-473F-A352-A628B3B29A8E@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1236246678 19352 80.91.229.12 (5 Mar 2009 09:51:18 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 5 Mar 2009 09:51:18 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Mar 05 10:52:35 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1LfAFk-0001gZ-LO for ged-emacs-devel@m.gmane.org; Thu, 05 Mar 2009 10:52:32 +0100 Original-Received: from localhost ([127.0.0.1]:39444 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LfAEP-0006MC-C1 for ged-emacs-devel@m.gmane.org; Thu, 05 Mar 2009 04:51:09 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LfACn-0005m2-5w for emacs-devel@gnu.org; Thu, 05 Mar 2009 04:49:29 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LfACk-0005jx-K3 for emacs-devel@gnu.org; Thu, 05 Mar 2009 04:49:27 -0500 Original-Received: from [199.232.76.173] (port=53184 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LfACk-0005jn-8x for emacs-devel@gnu.org; Thu, 05 Mar 2009 04:49:26 -0500 Original-Received: from main.gmane.org ([80.91.229.2]:39177 helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LfACj-00084k-T8 for emacs-devel@gnu.org; Thu, 05 Mar 2009 04:49:26 -0500 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1LfACg-0003SK-1c for emacs-devel@gnu.org; Thu, 05 Mar 2009 09:49:22 +0000 Original-Received: from dslb-084-061-040-202.pools.arcor-ip.net ([84.61.40.202]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 05 Mar 2009 09:49:22 +0000 Original-Received: from dak by dslb-084-061-040-202.pools.arcor-ip.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 05 Mar 2009 09:49:22 +0000 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 37 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: dslb-084-061-040-202.pools.arcor-ip.net User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) Cancel-Lock: sha1:l2g6olCiwAiGRyyxJytM1TobBHA= X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:109466 Archived-At: Geoff Gole 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 modes. (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 example. Also, in some cases you can't avoid lambda, namely when using computed functions. -- David Kastrup