emacs-devel
[Top][All Lists]
Advanced

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

[PATCH] Jumping to message by ID


From: Andrea Monaco
Subject: [PATCH] Jumping to message by ID
Date: Fri, 20 Oct 2023 10:09:55 +0200

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 via email to

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