all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Robert D. Crawford" <rdc1x@comcast.net>
To: help-gnu-emacs@gnu.org
Subject: Re: add-hook
Date: Wed, 06 Jun 2007 15:41:20 -0500	[thread overview]
Message-ID: <87tztkq0i7.fsf@comcast.net> (raw)
In-Reply-To: mailman.1634.1181129906.32220.help-gnu-emacs@gnu.org

Sebastian Tennant <sebyte@smolny.plus.com> 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)

  parent reply	other threads:[~2007-06-06 20:41 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.1634.1181129906.32220.help-gnu-emacs@gnu.org>
2007-06-06 12:04 ` add-hook Katsumi Yamaoka
2007-06-06 20:41 ` Robert D. Crawford [this message]
2013-01-25 19:03 add-hook Perry Smith
2013-01-25 19:18 ` add-hook Drew Adams
2013-01-26  4:03   ` add-hook Dmitry Gutov
     [not found]   ` <mailman.18346.1359173059.855.help-gnu-emacs@gnu.org>
2013-01-26  5:33     ` add-hook Barry Margolin
2013-01-26  6:21       ` add-hook Dmitry Gutov
  -- strict thread matches above, loose matches on Subject: below --
2011-06-04 13:00 add-hook daniele.g
2011-06-04 14:11 ` add-hook Teemu Likonen
2011-06-04 18:35   ` add-hook daniele.g
2011-06-05 10:58     ` add-hook Richard Riley
2011-06-05 18:58       ` add-hook daniele.g
2011-06-05 20:26         ` add-hook Richard Riley
2011-06-05 22:28           ` add-hook daniele.g
2011-06-05 23:33             ` add-hook Richard Riley
2007-06-06 11:26 add-hook Sebastian Tennant
2007-06-07  0:20 ` add-hook Sebastian Tennant
     [not found] ` <mailman.1696.1181175524.32220.help-gnu-emacs@gnu.org>
2007-06-07  7:16   ` add-hook Thien-Thi Nguyen
2007-06-07 10:00     ` add-hook Sebastian Tennant
     [not found]     ` <mailman.1711.1181210337.32220.help-gnu-emacs@gnu.org>
2007-06-07 14:01       ` add-hook Thien-Thi Nguyen
2003-11-10  3:01 add-hook Richard Stallman
2003-11-10  5:07 ` add-hook Miles Bader
2003-11-10 15:41   ` add-hook Stefan Monnier
2003-11-11  2:26     ` add-hook Miles Bader
2003-11-12 20:02       ` add-hook Richard Stallman
2003-11-11 18:22   ` add-hook Richard Stallman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87tztkq0i7.fsf@comcast.net \
    --to=rdc1x@comcast.net \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.