Last active
June 30, 2020 23:30
-
-
Save agzam/96484ff6c1f52d215430d6070ee9dde7 to your computer and use it in GitHub Desktop.
Mu4e action to find a message in mailing list archives
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; 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)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.