From: Emanuel Berg <moasen@zoho.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Is there a way to get the last message?
Date: Mon, 29 May 2017 00:11:51 +0200 [thread overview]
Message-ID: <yw.86wp90eimw.fsf@zoho.com> (raw)
In-Reply-To: 87lgphp6ug.fsf@rosalinde
Stephen Berman wrote:
> 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))))
>
> (add-hook 'post-command-hook
> 'get-last-message)
Oh, no!
So there were this suggestion already!
Well, hell, anyway I also attempted it:
(defun get-last-message ()
(interactive)
(let ((message-buffer (get-buffer "*Messages*")))
(when message-buffer
(with-temp-buffer
(insert-buffer-substring message-buffer)
(goto-char (point-max))
(forward-line -1)
(let ((start (point-at-bol))
(end (point-at-eol)) )
(buffer-substring start end) )))))
;; test:
;;
;; (message "I was afraid you'd be trapped outside the city.")
;; (message "Hey, I wasn't worried for a microsecond!")
;; (message "Then you probably didn't understand the situation.")
;;
;; (get-last-message)
--
underground experts united
http://user.it.uu.se/~embe8573
next prev parent reply other threads:[~2017-05-28 22:11 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-28 10:50 Is there a way to get the last message? Marcin Borkowski
2017-05-28 11:18 ` Stephen Berman
2017-05-28 11:41 ` John Ankarström
2017-05-29 18:51 ` Emanuel Berg
2017-05-28 14:12 ` Marcin Borkowski
2017-05-28 22:11 ` Emanuel Berg [this message]
2017-05-28 11:51 ` tomas
2017-05-28 18:24 ` Emanuel Berg
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=yw.86wp90eimw.fsf@zoho.com \
--to=moasen@zoho.com \
--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.