From: Steinar Bang <sb@dod.no>
Subject: Re: executing a lisp command as a hook
Date: Fri, 28 Apr 2006 09:58:43 +0200 [thread overview]
Message-ID: <87d5f2ku6k.fsf@dod.no> (raw)
In-Reply-To: 1146179269.179185.88680@j33g2000cwa.googlegroups.com
>>>>> mmuurr@gmail.com:
> So I tried a simple elisp function:
> (message jde-project-name)
> This works when I execute the command from a scratch buffer using C-c
> C-e, but if I include that command as is in the hook line (set using a
> configure-variable interface) I get this is a response in the echo
> area:
> Invalid function: (message jde-project-name)
I'm guessing that's because (message jde-project-name) by itself isn't
a function. It's a function call.
Did you try doing something like this?
(add-hook 'my-hook '(message jde-project-name))
?
> Can anyone tell me how to provide a way to call an elisp function from
> a hook variable?
You can use an anonymous lambda function, or define a function with a
name and use the name. I prefer using named functions, because they
are easier to recognize when looking at the hook's value, and easier
to remove.
Using a lambda it would be something like this:
(add-hook 'my-hook '(lambda () (message jde-project-name)))
Using a named function it would be something like this
(defun display-jde-project-name () (message jde-project-name))
(add-hook 'my-hook 'display-jde-project-name)
(though as was hinted at later in this thread, message may not be the
best function to use here)
prev parent reply other threads:[~2006-04-28 7:58 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-04-27 23:07 executing a lisp command as a hook mmuurr
2006-04-27 23:38 ` mmuurr
2006-04-28 0:33 ` Drew Adams
2006-04-28 7:58 ` Steinar Bang [this message]
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=87d5f2ku6k.fsf@dod.no \
--to=sb@dod.no \
/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.