mu4e: small code cleanups

Update some old code (we have 28.1 now); mostly:
- (= (length lst) x) ===> (length== lst x)
- (cdr (assoc ...)) ==> alist-get
This commit is contained in:
Dirk-Jan C. Binnema
2026-04-07 20:43:53 +03:00
committed by Seth Ladygo
parent 65b3dbb5c9
commit 0ca6389c03
8 changed files with 26 additions and 31 deletions

View File

@ -1,6 +1,6 @@
;;; mu4e-bookmarks.el --- Bookmarks handling -*- lexical-binding: t -*-
;; Copyright (C) 2011-2025 Dirk-Jan C. Binnema
;; Copyright (C) 2011-2026 Dirk-Jan C. Binnema
;; Author: Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
;; Maintainer: Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
@ -147,7 +147,7 @@ with KEY."
"Get `mu4e-bookmarks' in the (new) format.
Convert from the old format if needed."
(seq-map (lambda (item)
(if (and (listp item) (= (length item) 3))
(if (and (listp item) (length= item 3))
`(:name ,(nth 1 item) :query ,(nth 0 item)
:key ,(nth 2 item))
item))

View File

@ -1,6 +1,6 @@
;;; mu4e-contacts.el --- Dealing with contacts -*- lexical-binding: t -*-
;; Copyright (C) 2022-2025 Dirk-Jan C. Binnema
;; Copyright (C) 2022-2026 Dirk-Jan C. Binnema
;; Author: Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
;; Maintainer: Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
@ -236,7 +236,7 @@ The reverse of the RFC atext definition is then tested. If it
matches, nil is returned, if not, it returns a symbol
`rfc822-atom'."
(cond
((= (length ph) 0) 'rfc822-empty)
((length= ph 0) 'rfc822-empty)
((= (aref ph 0) ?\")
(if (string-match "\"\\([^\"\\\n]\\|\\\\.\\|\\\\\n\\)*\"" ph)
'rfc822-quoted-string

View File

@ -1,6 +1,6 @@
;;; mu4e-contrib.el --- User-contributed functions -*- lexical-binding: t -*-
;; Copyright (C) 2013-2023 Dirk-Jan C. Binnema
;; Copyright (C) 2013-2026 Dirk-Jan C. Binnema
;; This file is not part of GNU Emacs.
@ -155,12 +155,11 @@ the file."
(bufs nil)
;; Remove directories from the list
(files-to-attach
(delq nil (mapcar
(lambda (f) (if (or (not (file-exists-p f))
(file-directory-p f))
nil
(expand-file-name f)))
(mu4e--flatten-list (reverse args))))))
(seq-keep
(lambda (f) (when (and (file-exists-p f)
(not (file-directory-p f)))
(expand-file-name f)))
(mu4e--flatten-list (reverse args)))))
;; warn if user tries to attach without any files marked
(if (null files-to-attach)
(error "No files to attach")
@ -173,7 +172,7 @@ the file."
(if (and bufs
(y-or-n-p "Attach files to existing mail composition buffer? "))
(setq destination
(if (= (length bufs) 1)
(if (length= bufs 1)
(get-buffer (car bufs))
(let ((prompt (mu4e-format "%s" "Attach to buffer")))
(substring-no-properties

View File

@ -1,6 +1,6 @@
;;; mu4e-headers.el --- Message headers -*- lexical-binding: t -*-
;; Copyright (C) 2011-2025 Dirk-Jan C. Binnema
;; Copyright (C) 2011-2026 Dirk-Jan C. Binnema
;; Author: Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
;; Maintainer: Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
@ -1101,7 +1101,7 @@ If THREADS is non-nil, give a more informative error message."
(mapcar
(lambda (item)
(let* ((field (car item)) (width (cdr item))
(info (cdr (assoc field fields)))
(info (alist-get field fields))
(sortable-info (plist-get info :sortable))
;; the effective sort-field for this field is as per its info;
;; if t, it's the field itself; otherwise it's either some

View File

@ -1,6 +1,7 @@
;;; mu4e-icalendar.el --- iCalendar & diary integration -*- lexical-binding: t; -*-
;; Copyright (C) 2019-2023 Christophe Troestler
;; Copyright (C) 2019-2026 Christophe Troestler
;; Copyright (C) 2019-2026 Dirk-Jan C. Binnema
;; Author: Christophe Troestler <Christophe.Troestler@umons.ac.be>
;; Maintainer: Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
@ -106,7 +107,7 @@
(gnus-icalendar-event-reply-from-buffer
(current-buffer) status (gnus-icalendar-identities))))
(msg (mu4e-message-at-point 'noerror))
(charset (cdr (assoc 'charset (mm-handle-type handle)))))
(charset (alist-get 'charset (mm-handle-type handle))))
(when reply
(cl-labels
((fold-icalendar-buffer
@ -157,7 +158,7 @@
(mu4e--icalendar-insert-diary event status
mu4e-icalendar-diary-file)))))))))
(declare-function mu4e-view-headers-next "mu4e-view")
(defun mu4e--icalendar-trash-message (original-msg)
"Trash the message ORIGINAL-MSG and move to the next one."
(lambda (docid path)
@ -173,15 +174,9 @@
(when (and (mu4e~headers-view-this-message-p docid)
(buffer-live-p (mu4e-get-view-buffer)))
(mu4e-display-buffer (mu4e-get-view-buffer))
(or (mu4e-view-headers-next)
(or (mu4e-headers-next)
(kill-buffer-and-window))))))
;; (defun mu4e--icalendar-trash-message-hook (original-msg)
;; "Trash the iCalendar message ORIGINAL-MSG."
;; (lambda ()
;; (setq mu4e-sent-func
;; (mu4e--icalendar-trash-message original-msg))))
(defun mu4e--icalendar-insert-diary (event reply-status filename)
"Insert a diary entry for the EVENT in file named FILENAME.
REPLY-STATUS is the status of the reply. The possible values are

View File

@ -1,6 +1,6 @@
;;; mu4e-search.el --- Search-related functions -*- lexical-binding: t -*-
;; Copyright (C) 2021-2025 Dirk-Jan C. Binnema
;; Copyright (C) 2021-2026 Dirk-Jan C. Binnema
;; Author: Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
;; Maintainer: Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
@ -480,7 +480,7 @@ by the `:date' field."
;; note: 'sortable' is either a boolean (meaning: if non-nil, this is
;; sortable field), _or_ another field (meaning: sort by this other
;; field).
(sortable (plist-get (cdr (assoc field mu4e-header-info)) :sortable))
(sortable (plist-get (alist-get field mu4e-header-info) :sortable))
;; error check
(sortable
(if sortable

View File

@ -1,6 +1,7 @@
;;; mu4e-thread.el --- Thread folding support -*- lexical-binding: t -*-
;; Copyright (C) 2023 Nicolas P. Rougier
;; Copyright (C) 2023-2026 Dirk-Jan C. Binnema
;; Author: Nicolas P. Rougier <Nicolas.Rougier@inria.fr>
;; Keywords: mail
@ -161,7 +162,7 @@ Reset individual folding states."
(while (not (eobp))
(when-let* ((msg (get-text-property (point) 'msg))
(docid (mu4e-message-field msg :docid))
(state (cdr (assoc docid mu4e-thread--docids))))
(state (alist-get docid mu4e-thread--docids)))
(if (eq state 'folded)
(mu4e-thread-fold)
(mu4e-thread-unfold)))

View File

@ -235,7 +235,7 @@ any further, go the next message."
(scroll-up)
(error
(when mu4e-view-scroll-to-next
(mu4e-view-headers-next)))))
(mu4e-headers-next)))))
(defun mu4e-scroll-up ()
"Scroll text of selected window up one line."
@ -716,7 +716,7 @@ render. After inserting, highlight the headers."
(defun mu4e--view-gnus-insert-header (field val)
"Insert a header FIELD with value VAL."
(let* ((info (cdr (assoc field mu4e-header-info)))
(let* ((info (alist-get field mu4e-header-info))
(key (or (plist-get info :name)
;; Fallback for fields not in mu4e-header-info
;; (e.g. :user-agent): derive from the keyword name.
@ -728,8 +728,8 @@ render. After inserting, highlight the headers."
(defun mu4e--view-gnus-insert-header-custom (msg field)
"Insert MSG's custom FIELD."
(let* ((info (cdr-safe (or (assoc field mu4e-header-info-custom)
(mu4e-error "Custom field %S not found" field))))
(let* ((info (or (alist-get field mu4e-header-info-custom)
(mu4e-error "Custom field %S not found" field)))
(key (plist-get info :name))
(func (or (plist-get info :function)
(mu4e-error "No :function defined for custom field %S %S"