* executing a lisp command as a hook
@ 2006-04-27 23:07 mmuurr
2006-04-27 23:38 ` mmuurr
2006-04-28 7:58 ` Steinar Bang
0 siblings, 2 replies; 4+ messages in thread
From: mmuurr @ 2006-04-27 23:07 UTC (permalink / raw)
Hi all, I'm fairly new with emacs, so please bear with me if this is a
trivial question...
I have a hook variable that I'm trying to set. It's a variable
included in the JDE (Java Development Environment) for Emacs, and the
goal is for me to be able to display some text in the echo area when I
switch from project to project between buffers.
There is a variable associated with each project called
jde-project-name.
When I jump to a new project, I simply want to be notified of this in
the echo area.
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)
Can anyone tell me how to provide a way to call an elisp function from
a hook variable?
Thanks!
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: executing a lisp command as a hook
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
1 sibling, 1 reply; 4+ messages in thread
From: mmuurr @ 2006-04-27 23:38 UTC (permalink / raw)
OK, I figured it out! I'm doing the correct thing, however a whole
bunch of messages are displayed before and after the hook executes, so
I lose it in the echo area. Is there anyway to put a time on a
message, so it lingers in the echo area (maybe as other commands flash
by, but then goes back to the important status message I want).
Better yet, can anyone tell me how to append some information to the
information bar at the bottom of each window (the one that shows things
like line number, major-minor modes, etc...)
Thanks!
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: executing a lisp command as a hook
2006-04-27 23:38 ` mmuurr
@ 2006-04-28 0:33 ` Drew Adams
0 siblings, 0 replies; 4+ messages in thread
From: Drew Adams @ 2006-04-28 0:33 UTC (permalink / raw)
Is there anyway to put a time on a
message, so it lingers in the echo area (maybe as other commands flash
by, but then goes back to the important status message I want).
See function `sit-for' (and perhaps function `sleep-for').
Better yet, can anyone tell me how to append some information to the
information bar at the bottom of each window (the one that shows things
like line number, major-minor modes, etc...)
Look up `mode-line' in the Emac-Lisp manual.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: executing a lisp command as a hook
2006-04-27 23:07 executing a lisp command as a hook mmuurr
2006-04-27 23:38 ` mmuurr
@ 2006-04-28 7:58 ` Steinar Bang
1 sibling, 0 replies; 4+ messages in thread
From: Steinar Bang @ 2006-04-28 7:58 UTC (permalink / raw)
>>>>> 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)
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2006-04-28 7:58 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).