From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Idempotency of add-hook wrt lambda expressions Date: Thu, 05 Mar 2009 11:38:09 -0500 Message-ID: References: <74F2CF19-2E71-473F-A352-A628B3B29A8E@gmail.com> <861vtcxpt1.fsf@lola.quinscape.zz> <20090305164532.GC1855@muc.de> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1236271249 9870 80.91.229.12 (5 Mar 2009 16:40:49 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 5 Mar 2009 16:40:49 +0000 (UTC) Cc: David Kastrup , Geoff Gole , emacs-devel@gnu.org To: Alan Mackenzie Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Mar 05 17:42:04 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 1LfGdw-00036v-Of for ged-emacs-devel@m.gmane.org; Thu, 05 Mar 2009 17:41:57 +0100 Original-Received: from localhost ([127.0.0.1]:58481 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LfGcb-0004bl-5s for ged-emacs-devel@m.gmane.org; Thu, 05 Mar 2009 11:40:33 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LfGaU-0003N7-Pw for emacs-devel@gnu.org; Thu, 05 Mar 2009 11:38:22 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LfGaS-0003MK-Mi for emacs-devel@gnu.org; Thu, 05 Mar 2009 11:38:21 -0500 Original-Received: from [199.232.76.173] (port=51862 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LfGaS-0003MA-FD for emacs-devel@gnu.org; Thu, 05 Mar 2009 11:38:20 -0500 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.182]:39133) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LfGaK-0001Tn-9b; Thu, 05 Mar 2009 11:38:12 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AqIEAHuOr0nO+KX2/2dsb2JhbACBTthlhAgGhBI X-IronPort-AV: E=Sophos;i="4.38,308,1233550800"; d="scan'208";a="34737026" Original-Received: from 206-248-165-246.dsl.teksavvy.com (HELO pastel.home) ([206.248.165.246]) by ironport2-out.teksavvy.com with ESMTP; 05 Mar 2009 11:38:10 -0500 Original-Received: by pastel.home (Postfix, from userid 20848) id A2F4A7FA2; Thu, 5 Mar 2009 11:38:09 -0500 (EST) In-Reply-To: <20090305164532.GC1855@muc.de> (Alan Mackenzie's message of "Thu, 5 Mar 2009 16:45:32 +0000") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.91 (gnu/linux) X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. 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:109476 Archived-At: > 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