unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Emanuel Berg <moasenwood@zoho.eu>
To: emacs-devel@gnu.org
Subject: insert-last-message
Date: Fri, 01 Mar 2019 23:24:29 +0100	[thread overview]
Message-ID: <86sgw6p71e.fsf@zoho.eu> (raw)

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	other threads:[~2019-03-01 22:24 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-01 22:24 Emanuel Berg [this message]
2019-03-02  4:33 ` insert-last-message Marcin Borkowski
2019-03-02 19:29   ` insert-last-message 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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86sgw6p71e.fsf@zoho.eu \
    --to=moasenwood@zoho.eu \
    --cc=emacs-devel@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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).