From d393a44d17e1d1278bfa51de42abd0eedebf99f8 Mon Sep 17 00:00:00 2001 From: Kévin Le Gouguec Date: Sun, 29 Nov 2020 13:56:05 +0100 Subject: Expand notes on lists.gnu.org ↔ message-id mappings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - move function to correct section, and tweak it - add function for retrieving a lists.gnu.org URL from a message-id (unfinished, would like to automatically grab the list-id) - remove indentation; pandoc sees how the #+begin_src tag is indented and does TRT - say "emacs-lisp" instead of "elisp", as pandoc does not know the latter https://github.com/jgm/pandoc/blob/2.11.2/src/Text/Pandoc/Readers/Org/Shared.hs#L71 --- itches/emacs/development.org | 73 +++++++++++++++++++++++++++++++------------- 1 file changed, 52 insertions(+), 21 deletions(-) (limited to 'itches/emacs') diff --git a/itches/emacs/development.org b/itches/emacs/development.org index a3e05da..755330b 100644 --- a/itches/emacs/development.org +++ b/itches/emacs/development.org @@ -35,35 +35,66 @@ trick, e.g. * Mailing lists ** Message IDs *** Summary buffer → Message-ID -#+begin_src elisp +#+begin_src emacs-lisp (kill-new (mail-header-message-id (gnus-summary-article-header))) #+end_src *** TODO Message-ID → HTTP archive - : #+begin_example - https://lists.gnu.org/archive/cgi-bin/namazu.cgi - ?query=%2Bmessage-id:<$MESSAGE_ID> - &submit=Search! - &idxname=$LIST +https://lists.gnu.org/archive/cgi-bin/namazu.cgi + ?query=%2Bmessage-id:<$MESSAGE_ID> + &submit=Search! + &idxname=$LIST #+end_example ⇒ - #+begin_src elisp - (defun mhonarc-to-messageid (url) - "Retrieve the Message-ID from an article archived on MHonArc." - (interactive - (list - (let* ((default (or (thing-at-point-url-at-point) - (and (derived-mode-p 'eww-mode) - (shr-url-at-point nil)))) - (prompt (if default - (format "URL? (%s) " default) - "URL? "))) - (read-string prompt nil nil default)))) - (with-current-buffer (url-retrieve-synchronously url) - (search-forward-regexp "^$") - (message (xml-substitute-numeric-entities (match-string 1))))) + #+begin_src emacs-lisp +(defun messageid-to-lgo-url (list id) + "Find the lists.gnu.org URL for a given Message-ID." + (interactive + (list + (read-string "List: ") ; TODO: default to current list. + (let ((default-id + (mail-header-message-id (gnus-summary-article-header)))) + (read-string (format-prompt "Message-ID" default-id) + nil nil default-id)))) + (with-current-buffer + (url-retrieve-synchronously + (concat + ;; For some reason, literal "+" chars cause the search to fail. + ;; Escape them. + "https://lists.gnu.org/archive/cgi-bin/namazu.cgi" + "?query=%2Bmessage-id:" + (replace-regexp-in-string "\\+" "%2B" id) + "&submit=Search!" + "&idxname=" list)) + (search-forward-regexp + (rx "")) + (let ((url (concat "https://lists.gnu.org" (match-string 1)))) + (kill-new url) + (message url)))) #+end_src + - public-inbox: trivial -*** TODO HTTP archive → Message-ID +*** DONE HTTP archive → Message-ID - : cf. =X-Message-Id= comment in HTML + ⇒ + #+begin_src emacs-lisp +(defun mhonarc-to-messageid (url) + "Retrieve the Message-ID from an article archived on MHonArc." + (interactive + (list + (let ((default (or (thing-at-point-url-at-point) + (and (derived-mode-p 'eww-mode) + (shr-url-at-point nil))))) + (read-string (format-prompt "URL" default) nil nil default)))) + (with-current-buffer (url-retrieve-synchronously url) + (search-forward-regexp "^$") + (let ((id (xml-substitute-numeric-entities (match-string 1)))) + (kill-new id) + (message id)))) + #+end_src + - public-inbox: cf. URL -- cgit v1.2.3