mu4e-lists: modernize

Remove some obsolete mailing lists form the "built-in" ones.

Make the mailing list blob plists, so we can more easily add new ones.

Update the handler functions for this.
This commit is contained in:
Dirk-Jan C. Binnema
2023-05-04 20:47:42 +03:00
parent ada6ff6260
commit 88ec2b86ce

View File

@ -1,6 +1,6 @@
;;; mu4e-lists.el -- part of mu4e -*- lexical-binding: t -*- ;;; mu4e-lists.el -- part of mu4e -*- lexical-binding: t -*-
;; Copyright (C) 2011-2021 Dirk-Jan C. Binnema ;; Copyright (C) 2011-2023 Dirk-Jan C. Binnema
;; Author: Dirk-Jan C. Binnema <djcb@djcbsoftware.nl> ;; Author: Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
;; Maintainer: Dirk-Jan C. Binnema <djcb@djcbsoftware.nl> ;; Maintainer: Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
@ -29,103 +29,102 @@
;;; Configuration ;;; Configuration
(defvar mu4e-mailing-lists (defvar mu4e-mailing-lists
'( ("bbdb-info.lists.sourceforge.net" . "BBDB") '( (:list-id "bbdb-info.lists.sourceforge.net" :name "BBDB")
("boost-announce.lists.boost.org" . "BoostA") (:list-id "boost-announce.lists.boost.org" :name "BoostA")
("boost-interest.lists.boost.org" . "BoostI") (:list-id "boost-interest.lists.boost.org" :name "BoostI")
("conkeror.mozdev.org" . "Conkeror") (:list-id "curl-library.cool.haxx.se" :name "LibCurl")
("curl-library.cool.haxx.se" . "LibCurl") (:list-id "dbus.lists.freedesktop.org" :name "DBus")
("crypto-gram-list.schneier.com " . "CryptoGr") (:list-id "desktop-devel-list.gnome.org" :name "GnomeDT")
("dbus.lists.freedesktop.org" . "DBus") (:list-id "discuss-webrtc.googlegroups.com" :name "WebRTC")
("desktop-devel-list.gnome.org" . "GnomeDT") (:list-id "emacs-devel.gnu.org" :name "EmacsDev")
("discuss-webrtc.googlegroups.com" . "WebRTC") (:list-id "emacs-orgmode.gnu.org" :name "Orgmode")
("emacs-devel.gnu.org" . "EmacsDev") (:list-id "emms-help.gnu.org" :name "Emms")
("emacs-orgmode.gnu.org" . "Orgmode") (:list-id "evolution-hackers.lists.ximian.com" :name "EvoDev")
("emms-help.gnu.org" . "Emms") (:list-id "mailman.lists.freedesktop.org" :name "FDeskTop")
("enlightenment-devel.lists.sourceforge.net" . "E-Dev") (:list-id "gcc-help.gcc.gnu.org" :name "Gcc")
("erlang-questions.erlang.org" . "Erlang") (:list-id "gmime-devel-list.gnome.org" :name "GMimeDev")
("evolution-hackers.lists.ximian.com" . "EvoDev") (:list-id "gnome-shell-list.gnome.org" :name "GnomeSh")
("farsight-devel.lists.sourceforge.net" . "Farsight") (:list-id "gnu-emacs-sources.gnu.org" :name "EmacsSrc")
("mailman.lists.freedesktop.org" . "FDeskTop") (:list-id "gnupg-users.gnupg.org" :name "GnupgU")
("gcc-help.gcc.gnu.org" . "Gcc") (:list-id "gstreamer-devel.lists.freedesktop.org" :name "GstDev")
("gmime-devel-list.gnome.org" . "GMimeDev") (:list-id "gtk-devel-list.gnome.org" :name "GtkDev")
("gnome-shell-list.gnome.org" . "GnomeSh") (:list-id "gtkmm-list.gnome.org" :name "GtkmmDev")
("gnu-emacs-sources.gnu.org" . "EmacsSrc") (:list-id "guile-devel.gnu.org" :name "GuileDev")
("gnupg-users.gnupg.org" . "GnupgU") (:list-id "guile-user.gnu.org" :name "GuileUsr")
("gpe.handhelds.org" . "GPE") (:list-id "help-gnu-emacs.gnu.org" :name "EmacsUsr")
("gstreamer-devel.lists.freedesktop.org" . "GstDev") (:list-id "mu-discuss.googlegroups.com" :name "Mu")
("gstreamer-devel.lists.sourceforge.net" . "GstDev") (:list-id "nautilus-list.gnome.org" :name "Nautilus")
("gstreamer-openmax.lists.sourceforge.net" . "GstOmx") (:list-id "notmuch.notmuchmail.org" :name "Notmuch")
("gtk-devel-list.gnome.org" . "GtkDev") (:list-id "sqlite-announce.sqlite.org" :name "SQliteAnn")
("gtkmm-list.gnome.org" . "GtkmmDev") (:list-id "sqlite-dev.sqlite.org" :name "SQLiteDev")
("guile-devel.gnu.org" . "GuileDev") (:list-id "xapian-discuss.lists.xapian.org" :name "Xapian")
("guile-user.gnu.org" . "GuileUsr") (:list-id "xdg.lists.freedesktop.org" :name "XDG")
("help-gnu-emacs.gnu.org" . "EmacsUsr") (:list-id "wl-en.lists.airs.net" :name "Wdrlust")
("lggdh-algemeen.vvtp.tudelft.nl" . "LGGDH") (:list-id "wl-en.ml.gentei.org" :name "WdrLust")
("linux-bluetooth.vger.kernel.org" . "Bluez") (:list-id "xapian-devel.lists.xapian.org" :name "Xapian")
("maemo-developers.maemo.org" . "MaemoDev") (:list-id "zsh-users.zsh.org" :name "ZshUsr"))
("maemo-users.maemo.org" . "MaemoUsr") "List of plists with keys:
("monit-general.nongnu.org" . "Monit") - `:list-id' - the mailing list id
("mu-discuss.googlegroups.com" . "Mu") - `:name' - the display name.")
("nautilus-list.gnome.org" . "Nautilus")
("notmuch.notmuchmail.org" . "Notmuch")
("orbit-list.gnome.org" . "ORBit")
("pulseaudio-discuss.lists.freedesktop.org" . "PulseA")
("sqlite-announce.sqlite.org" . "SQliteAnn")
("sqlite-dev.sqlite.org" . "SQLiteDev")
("sup-talk.rubyforge.org" . "Sup")
("sylpheed-claws-users.lists.sourceforge.net" . "Sylpheed")
("tinymail-devel-list.gnome.org" . "Tinymail")
("unicode.sarasvati.unicode.org" . "Unicode")
("xapian-discuss.lists.xapian.org" . "Xapian")
("xdg.lists.freedesktop.org" . "XDG")
("wl-en.lists.airs.net" . "Wdrlust")
("wl-en.ml.gentei.org" . "WdrLust")
("xapian-devel.lists.xapian.org" . "Xapian")
("zsh-users.zsh.org" . "ZshUsr"))
"AList of cells (MAILING-LIST-ID . SHORTNAME).")
(defcustom mu4e-user-mailing-lists nil (defcustom mu4e-user-mailing-lists nil
"An alist with cells (MAILING-LIST-ID . SHORTNAME). "A list with plists like `mu4e-mailing-lists'.
These are used in addition to the built-in list `mu4e-mailing-lists'." These are used in addition to the built-in list
:group 'mu4e-headers `mu4e-mailing-lists'.
:type '(repeat (cons string string)))
(defcustom mu4e-mailing-list-patterns nil The older format, a list of cons cells,
(LIST-ID . NAME)
is still supported for backward compatibility, but
you are encouraged to use the new format."
:group 'mu4e-headers
:type '(repeat (plist)))
(defcustom mu4e-mailing-list-patterns '("\\([^.]*\\)\\.")
"A list of regexps to capture a shortname out of a list-id. "A list of regexps to capture a shortname out of a list-id.
For the first regex that matches, its first matchgroup will be For the first regex that matches, its first match-group will be
used as the shortname." used as the shortname."
:group 'mu4e-headers :group 'mu4e-headers
:type '(repeat (regexp))) :type '(repeat (regexp)))
(defvar mu4e--lists-hash nil (defvar mu4e--lists-hash nil
"Hashtable of mailing-list-id => shortname. "Hash-table of list-id => plist.
Based on `mu4e-mailing-lists' and `mu4e-user-mailing-lists'.") Based on `mu4e-mailing-lists' and `mu4e-user-mailing-lists'.")
(defun mu4e-mailing-list-info-refresh ()
"Refresh the mailing list info.
Based on the current value of `mu4e-mailing-lists' and
`mu4e-user-mailing-lists'."
(interactive)
(setq mu4e--lists-hash (make-hash-table :test 'equal))
(seq-do (lambda (item)
(message "%S %s" item (plistp item))
(if (plistp item)
;; the new format
(puthash (plist-get item :list-id) item mu4e--lists-hash)
;; backward compatibility
(puthash (car item) (cdr item) mu4e--lists-hash)))
(append mu4e-mailing-lists
mu4e-user-mailing-lists)))
(defun mu4e-mailing-list-info (list-id)
"Get mailing list info for LIST-ID.
Return nil if not found."
(unless mu4e--lists-hash (mu4e-mailing-list-info-refresh))
(gethash list-id mu4e--lists-hash))
(defun mu4e-get-mailing-list-shortname (list-id) (defun mu4e-get-mailing-list-shortname (list-id)
"Get the shortname for a mailing-list with list-id LIST-ID. "Get the shortname for a mailing-list with list-id LIST-ID.
Based on `mu4e-mailing-lists', `mu4e-user-mailing-lists', and Either we know about this mailing list, or otherwise
`mu4e-mailing-list-patterns'." we guess one."
(unless mu4e--lists-hash (or ;; 1. perhaps we have it in one of our lists?
(setq mu4e--lists-hash (make-hash-table :test 'equal)) (plist-get (mu4e-mailing-list-info list-id) :name)
(dolist (cell mu4e-mailing-lists) ;; 2. see if it matches some pattern
(puthash (car cell) (cdr cell) mu4e--lists-hash)) (if (seq-find (lambda (p) (string-match p list-id))
(dolist (cell mu4e-user-mailing-lists) mu4e-mailing-list-patterns)
(puthash (car cell) (cdr cell) mu4e--lists-hash)))
(or
(gethash list-id mu4e--lists-hash)
(and (boundp 'mu4e-mailing-list-patterns)
(seq-drop-while
(lambda (pattern)
(not (string-match pattern list-id)))
mu4e-mailing-list-patterns)
(match-string 1 list-id))
;; if it's not in the db, take the part until the first dot if there is one;
;; otherwise just return the whole thing
(if (string-match "\\([^.]*\\)\\." list-id)
(match-string 1 list-id) (match-string 1 list-id)
;; 3. otherwise, just return the whole thing
list-id))) list-id)))
;;; _
(provide 'mu4e-lists) (provide 'mu4e-lists)
;;; mu4e-lists.el ends here ;;; mu4e-lists.el ends here