help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

## Re: Is there a way to get the last message?

 From: Marcin Borkowski Subject: Re: Is there a way to get the last message? Date: Sun, 28 May 2017 16:12:37 +0200 User-agent: mu4e 0.9.19; emacs 26.0.50

```On 2017-05-28, at 13:18, Stephen Berman <address@hidden> wrote:

> On Sun, 28 May 2017 12:50:12 +0200 Marcin Borkowski <address@hidden> wrote:
>
>> Hi all,
>>
>> I know about (current-message).  However, this won't work:
>>
>> (defun get-last-message ()
>>   "Try to get the last message."
>>   (interactive)
>>   (with-temp-buffer
>>     (insert (or (current-message) ""))
>>     (clipboard-kill-ring-save (point-min) (point-max))))
>>
>> M-x get-last-message puts the empty string into the clipboard and kill
>> ring.
>>
>> Apparently `current-message' is cleared before this command has a chance
>> to get it.  This makes sense, but there is no `previous-message' command.
>>
>> Is there any way to get the last thing displayed in the echo area (from
>> `message' or possibly from `error', too)?  This would be quite useful:
>> one could then paste it to a search engine to look up the internet for
>> some hints about the error/message.
>
> What about this:
>
> (defun get-last-message ()
>   "Try to get the last message."
>   (interactive)
>   (with-current-buffer "*Messages*"
>     (goto-char (point-max))
>     (forward-line -1)
>     (clipboard-kill-ring-save (line-beginning-position) (line-end-position))))

Thanks, I thought about something like that, too.  It has one problem,
though:

(defun long-message ()
(interactive)
(message "Long\nmessage"))

Thanks anyway,

--
Marcin Borkowski

```

reply via email to

 [Prev in Thread] Current Thread [Next in Thread]