* using (current-message) bound to a key
@ 2013-07-11 9:56 Nicolas Richard
2013-07-11 10:35 ` Peter Dyballa
0 siblings, 1 reply; 3+ messages in thread
From: Nicolas Richard @ 2013-07-11 9:56 UTC (permalink / raw)
To: help-gnu-emacs
Hello,
I'm trying to access what's located in the echo area. I failed. Could
someone explain what I'm doing wrong ?
(defun show-current-message ()
(interactive)
(insert (format "%s" (current-message))))
(global-set-key (kbd "<f5>") 'show-current-message)
That doesn't work, e.g. if I write "'foo" and then hit the
keys: C-x e <f5>, I get "nil" inserted whereas I expected to have
"foo" inserted.
Perhaps the way C-x e works is getting in the way, so I try this:
(defun say-hi ()
(interactive)
(message "hi"))
(global-set-key (kbd "<f6>") 'say-hi)
then hitting succesively f6 and f5 inserts again "nil" instead of the
expected "hi".
On the other hand,
(progn
(message "hi")
(call-interactively 'show-current-message))
inserts "hi" as expected.
So there is something wrong with me binding show-current-message to a
key. How to work around this ?
Thanks
--
Nico.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: using (current-message) bound to a key
2013-07-11 9:56 using (current-message) bound to a key Nicolas Richard
@ 2013-07-11 10:35 ` Peter Dyballa
2013-07-11 11:06 ` Nicolas Richard
0 siblings, 1 reply; 3+ messages in thread
From: Peter Dyballa @ 2013-07-11 10:35 UTC (permalink / raw)
To: Nicolas Richard; +Cc: help-gnu-emacs
Am 11.07.2013 um 11:56 schrieb Nicolas Richard:
> I'm trying to access what's located in the echo area.
You can find it also in *Messages* buffer…
--
Greetings
Pete
You can learn many things from children. How much patience you have, for instance.
– Franklin P. Jones
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: using (current-message) bound to a key
2013-07-11 10:35 ` Peter Dyballa
@ 2013-07-11 11:06 ` Nicolas Richard
0 siblings, 0 replies; 3+ messages in thread
From: Nicolas Richard @ 2013-07-11 11:06 UTC (permalink / raw)
To: Peter Dyballa; +Cc: help-gnu-emacs
Peter Dyballa <Peter_Dyballa@Web.DE> writes:
> Am 11.07.2013 um 11:56 schrieb Nicolas Richard:
>
>> I'm trying to access what's located in the echo area.
>
> You can find it also in *Messages* buffer…
Yes, thank you, but while this is true most of the time, it is not
always true -- and sometimes the text is slightly different (usually: a
"user-error: " or "call-interactively: " can be prepended, or " [n
times]" can be appended).
I do admit that the following would be good enough in all cases I can
think of:
(with-current-buffer "*Messages*"
(save-excursion
(goto-char (point-max))
(skip-chars-backward "\n")
(buffer-substring-no-properties (point)
(progn
(skip-chars-backward "^\n")
(point)))))
--
Nicolas
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-07-11 11:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-11 9:56 using (current-message) bound to a key Nicolas Richard
2013-07-11 10:35 ` Peter Dyballa
2013-07-11 11:06 ` Nicolas Richard
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).