summaryrefslogtreecommitdiff
path: root/mu4e
diff options
context:
space:
mode:
authorDirk-Jan C. Binnema <djcb@djcbsoftware.nl>2026-04-07 20:43:53 +0300
committerDirk-Jan C. Binnema <djcb@djcbsoftware.nl>2026-04-07 16:52:34 +0300
commit772d052a1a74b41cdb5c76875fc38bcf879fe896 (patch)
tree6e5dfcada369840c8c0a05360124b535a3217035 /mu4e
parent4f7350f93f57abf725db2c0781cbd46b2fec4096 (diff)
mu4e: small code cleanups
Update some old code (we have 28.1 now); mostly: - (= (length lst) x) ===> (length== lst x) - (cdr (assoc ...)) ==> alist-get
Diffstat (limited to 'mu4e')
-rw-r--r--mu4e/mu4e-bookmarks.el4
-rw-r--r--mu4e/mu4e-contacts.el4
-rw-r--r--mu4e/mu4e-contrib.el15
-rw-r--r--mu4e/mu4e-headers.el4
-rw-r--r--mu4e/mu4e-icalendar.el15
-rw-r--r--mu4e/mu4e-search.el4
-rw-r--r--mu4e/mu4e-thread.el3
-rw-r--r--mu4e/mu4e-view.el8
8 files changed, 26 insertions, 31 deletions
diff --git a/mu4e/mu4e-bookmarks.el b/mu4e/mu4e-bookmarks.el
index 1bc80e1..edecc31 100644
--- a/mu4e/mu4e-bookmarks.el
+++ b/mu4e/mu4e-bookmarks.el
@@ -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))
diff --git a/mu4e/mu4e-contacts.el b/mu4e/mu4e-contacts.el
index 1a63d40..3f7c274 100644
--- a/mu4e/mu4e-contacts.el
+++ b/mu4e/mu4e-contacts.el
@@ -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
diff --git a/mu4e/mu4e-contrib.el b/mu4e/mu4e-contrib.el
index 1da3c9b..d763064 100644
--- a/mu4e/mu4e-contrib.el
+++ b/mu4e/mu4e-contrib.el
@@ -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
diff --git a/mu4e/mu4e-headers.el b/mu4e/mu4e-headers.el
index a383401..3e2346e 100644
--- a/mu4e/mu4e-headers.el
+++ b/mu4e/mu4e-headers.el
@@ -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
diff --git a/mu4e/mu4e-icalendar.el b/mu4e/mu4e-icalendar.el
index 82a18f8..ae2e694 100644
--- a/mu4e/mu4e-icalendar.el
+++ b/mu4e/mu4e-icalendar.el
@@ -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
diff --git a/mu4e/mu4e-search.el b/mu4e/mu4e-search.el
index 3ef3c38..d694b65 100644
--- a/mu4e/mu4e-search.el
+++ b/mu4e/mu4e-search.el
@@ -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
diff --git a/mu4e/mu4e-thread.el b/mu4e/mu4e-thread.el
index 2f093b8..1a94fe8 100644
--- a/mu4e/mu4e-thread.el
+++ b/mu4e/mu4e-thread.el
@@ -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)))
diff --git a/mu4e/mu4e-view.el b/mu4e/mu4e-view.el
index 59951ce..ef685b7 100644
--- a/mu4e/mu4e-view.el
+++ b/mu4e/mu4e-view.el
@@ -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"