From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Andrea Monaco Newsgroups: gmane.emacs.devel Subject: [PATCH] Jumping to message by ID Date: Fri, 20 Oct 2023 10:09:55 +0200 Message-ID: <87bkctiujw.fsf@autistici.org> References: <83edj7vhb0.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32949"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Oct 20 10:11:07 2023 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qtkb5-0008PM-Ib for ged-emacs-devel@m.gmane-mx.org; Fri, 20 Oct 2023 10:11:07 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qtka8-0004e8-9j; Fri, 20 Oct 2023 04:10:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qtka5-0004dp-Va for emacs-devel@gnu.org; Fri, 20 Oct 2023 04:10:05 -0400 Original-Received: from confino.investici.org ([93.190.126.19]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qtka3-0002kW-9L; Fri, 20 Oct 2023 04:10:05 -0400 Original-Received: from mx1.investici.org (unknown [127.0.0.1]) by confino.investici.org (Postfix) with ESMTP id 4SBch458LYz11BY; Fri, 20 Oct 2023 08:09:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=autistici.org; s=stigmate; t=1697789396; bh=tFtM/5nnmIjB5O2uIwWfJXa2iKfZlzNWrBcJPi7cbfo=; h=From:To:Cc:Subject:In-Reply-To:Date:From; b=pkPPjiHT/pz6WlUJgQVMezhHgUZiEy4qVp00fVUdB+Ng6lvoPIaJl67FvRJQM9vjq JmG6+vKzWtH/s+YpSM4ItK4eVgaHGE3OWtdG76Uhke6Y1H3HeY3tZ5qWJ0oc33Ydkb Bdfjv+UUKNgtVp8+7TEpK6W464j5E4TSX0s5e75w= Original-Received: from [93.190.126.19] (mx1.investici.org [93.190.126.19]) (Authenticated sender: andrea.monaco@autistici.org) by localhost (Postfix) with ESMTPSA id 4SBch44J67z11BL; Fri, 20 Oct 2023 08:09:56 +0000 (UTC) In-Reply-To: <83edj7vhb0.fsf@gnu.org> (message from Eli Zaretskii on Sat, 09 Sep 2023 12:15:15 +0300) Received-SPF: pass client-ip=93.190.126.19; envelope-from=andrea.monaco@autistici.org; helo=confino.investici.org X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:311619 Archived-At: 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