unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Andrea Monaco <andrea.monaco@autistici.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: emacs-devel@gnu.org
Subject: [PATCH] Jumping to message by ID
Date: Fri, 20 Oct 2023 10:09:55 +0200	[thread overview]
Message-ID: <87bkctiujw.fsf@autistici.org> (raw)
In-Reply-To: <83edj7vhb0.fsf@gnu.org> (message from Eli Zaretskii on Sat, 09 Sep 2023 12:15:15 +0300)


diff --git a/lisp/mail/rmail.el b/lisp/mail/rmail.el
index f76600000c9..aaccf8b9b24 100644
--- a/lisp/mail/rmail.el
+++ b/lisp/mail/rmail.el
@@ -2699,6 +2699,35 @@ rmail-show-message
     (if blurb
 	(message blurb))))
 
+(defun rmail-get-email-address-at-point ()
+  "Return the email address or message id around point, or nil if none is present."
+  (save-mark-and-excursion
+    (let ((p (point)))
+      (unless (= p (point-max))
+	(forward-char))
+      (if (and
+	   (search-backward "<" nil t)
+	   (let ((end (re-search-forward "<.*@.*>" nil t)))
+	     (and end (> end p))))
+	  (match-string 0)))))
+
+(defun rmail-show-message-by-id (&optional id)
+  "Show message with given Message ID, defaulting to the id around point."
+  (interactive
+   (list (rmail-get-email-address-at-point)))
+  (unless id
+    (error "No message ID around point"))
+  (let ((id (rmail-get-email-address-at-point)))
+    (when id
+      (unless (and rmail-summary-message-parents-vector
+		   (= (length rmail-summary-message-parents-vector)
+		      (1+ rmail-total-messages)))
+	(rmail-summary-fill-message-parents-and-descs-vectors))
+      (let ((entry (assoc id (gethash id rmail-summary-message-ids-hash-table))))
+	(if entry
+	    (rmail-show-message (cdr entry))
+	  (error (concat "No message with ID " id " found")))))))
+
 (defun rmail-is-text-p ()
   "Return t if the region contains a text message, nil otherwise."
   (save-excursion



New command to jump to a message with the ID around point

* lisp/mail/rmail.el (rmail-get-email-address-at-point)
    (rmail-show-message-by-id): New functions.



Andrea Monaco



  reply	other threads:[~2023-10-20  8:09 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-09  9:00 Jumping to message by ID Andrea Monaco
2023-09-09  9:15 ` Eli Zaretskii
2023-10-20  8:09   ` Andrea Monaco [this message]
2023-10-20 10:26     ` [PATCH] " Eli Zaretskii
2023-10-20 17:26       ` Andrea Monaco
2023-10-20 23:44         ` Adam Porter
2023-10-23  2:08     ` Richard Stallman

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=87bkctiujw.fsf@autistici.org \
    --to=andrea.monaco@autistici.org \
    --cc=eliz@gnu.org \
    --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).