From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Robert D. Crawford" Newsgroups: gmane.emacs.help Subject: Re: add-hook Date: Wed, 06 Jun 2007 15:41:20 -0500 Message-ID: <87tztkq0i7.fsf@comcast.net> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1181170363 22584 80.91.229.12 (6 Jun 2007 22:52:43 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 6 Jun 2007 22:52:43 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Jun 07 00:52:41 2007 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Hw4Mq-0002bQ-LX for geh-help-gnu-emacs@m.gmane.org; Thu, 07 Jun 2007 00:52:40 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Hw4Mq-0000rw-5Q for geh-help-gnu-emacs@m.gmane.org; Wed, 06 Jun 2007 18:52:40 -0400 Original-Path: shelby.stanford.edu!headwall.stanford.edu!newshub.sdsu.edu!border1.nntp.dca.giganews.com!nntp.giganews.com!local01.nntp.dca.giganews.com!nntp.comcast.com!news.comcast.com.POSTED!not-for-mail Original-NNTP-Posting-Date: Wed, 06 Jun 2007 15:41:28 -0500 Original-Newsgroups: gnu.emacs.help User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1.50 (gnu/linux) Cancel-Lock: sha1:ei88mVMxw712K9ht4Idr5iEmHl0= Original-Lines: 41 Original-NNTP-Posting-Host: 68.52.51.66 Original-X-Trace: sv3-1Iy/xKMqZ2vVWK5QMT2vvfxV3zrYpTzbdb49eP168paX4Lko6qb8FX0XKqB+miCbwajg3thhw5PToih!UIcDYxm/i8vZknW1C0EDxHaK2NZLoCjuRq8yLuV76eleobGtZJJ/mDLu5gEEWYEqUgtuxDyfzc5D!sto= Original-X-Complaints-To: abuse@comcast.net X-DMCA-Complaints-To: dmca@comcast.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.34 Original-Xref: shelby.stanford.edu gnu.emacs.help:149138 X-Mailman-Approved-At: Wed, 06 Jun 2007 18:50:34 -0400 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:44727 Archived-At: Sebastian Tennant writes: > Am I right in thinking this is OK: > > (add-hook 'foo-hook 'bar-function 'baz-function ...) As I understand it, no. Only one function can be added to a hook at a time. This is what the lambda is for. In effect it creates a single function from multiple functions when only one function can be used. For example: (add-hook 'emacs-lisp-mode-hook '(lambda () (make-local-hook 'after-save-hook) (add-hook 'after-save-hook '(lambda () (byte-compile-file buffer-file-name)) nil t))) Everything contained within the lambda on line 2 is considered one item. > That is to say, single functions passed via add-hook are added to a > list the contents of which are evaluated in turn, but a lambda > function passed via add-hook is evaluated as it stands, (no list of > functions is created) so there can be only one lambda function passed > via add-hook at any one time? I am not sure what exactly you mean here. I _think_ you can run add-hook multiple times for the same hook in the same file using lambda each time, as inefficient as it may be. I hope this answers your questions, rdc -- Robert D. Crawford rdc1x@comcast.net BOFH excuse #351: PEBKAC (Problem Exists Between Keyboard And Chair)