[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Is there a way to get the last message?
From: |
Emanuel Berg |
Subject: |
Re: Is there a way to get the last message? |
Date: |
Mon, 29 May 2017 00:11:51 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) |
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