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

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

insert-last-message


From: Emanuel Berg
Subject: insert-last-message
Date: Fri, 01 Mar 2019 23:20:38 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

I just wrote this:

(defun insert-last-message ()
  (interactive)
  (insert
   (with-current-buffer (messages-buffer)
     (let ((end   (goto-char (point-max)))
           (start (re-search-backward "^[[:space:]]*[[:graph:]]+")) )
       (buffer-substring start end) ))))
(defalias 'ilm #'insert-last-message)

Again, this is another example of something
that seems to work, but it doesn't look good,
and I'm pretty sure it won't work in all cases
(e.g., multiline messages, possibly also
messages with wierd chars etc).

What I would like to have, and what I think
would be the sound solution, is to have a
data structure, a stack list, with the most
recent messages. One could have a variable to
specify the desired length of that list.
Every message would then go into that list, and
be accessed LIFO.

After that, one could easily even do
prefix args to access/output/insert not the
last, but the second last message, or any
message stored, if one can keep track of them
that is :)

Also, one could have a "blacklist" with
uninteresting messages, that would never enter
the list. Perhaps even a regexp blacklist, if
that wouldn't be too slow (?).

And when all of it still fails, one could still
use the *Messages* buffer and get whatever
one wants!

Is this a difficult thing to do? 

Source:

    http://user.it.uu.se/~embe8573/emacs-init/my-misc.el

-- 
underground experts united
http://user.it.uu.se/~embe8573




reply via email to

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