Skip to content

Instantly share code, notes, and snippets.

@agzam
Last active June 30, 2020 23:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agzam/96484ff6c1f52d215430d6070ee9dde7 to your computer and use it in GitHub Desktop.
Save agzam/96484ff6c1f52d215430d6070ee9dde7 to your computer and use it in GitHub Desktop.
Mu4e action to find a message in mailing list archives
;; If you subscribed to mailing list(s) in gnu.org or googlegroups.com
;; and using mu4e as your mailing app, very often you need to
;; find a message in lists.gnu.org/archive or googlegroups.com
;;
;; For example, when you don't have the context of a particular thread
;; and all prior messages got deleted locally.
;;
;; This mu4e action allows you
;; to quickly find selected email post in the archive
;; and open in the browser
(defun mu4e-action-find-in-mailing-list (msg)
"Find message in mailing-list archives"
(interactive)
(let* ((mlist (mu4e-message-field msg :mailing-list))
(msg-id (mu4e-message-field msg :message-id))
(url
(pcase mlist
;; gnu.org
((pred (lambda (x) (string-suffix-p "gnu.org" x)))
(concat
"https://lists.gnu.org/archive/cgi-bin/namazu.cgi?query="
(concat
(url-hexify-string
(concat
"+message-id:<"
msg-id
">"))
"&submit=" (url-hexify-string "Search!")
"&idxname="
(replace-regexp-in-string "\.gnu\.org" "" mlist))))
;; google.groups
((pred (lambda (x) (string-suffix-p "googlegroups.com" x)))
(concat
"https://groups.google.com/forum/#!topicsearchin/"
(replace-regexp-in-string "\.googlegroups\.com" "" mlist)
"/messageid$3A"
(url-hexify-string (concat "\"" msg-id "\"")))))))
(when url
(message "opening url: " url)
(browse-url url))))
(add-to-list 'mu4e-view-actions '("Find in mailing-list" . mu4e-action-find-in-mailing-list))
(add-to-list 'mu4e-headers-actions '("Find in mailing-list" . mu4e-action-find-in-mailing-list))
@agzam
Copy link
Author

agzam commented Jan 5, 2020

Basically, the idea is to retrieve message-id and mailing-list id from the message and based on those, attempt to find the message in the archives. It can probably be adapted to be used with other clients like notmuch and gnus and other mailing lists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment