mu4e: ignore bookmarks/maildirs without characterp keys

This commit is contained in:
Dirk-Jan C. Binnema 2023-01-19 00:28:43 +02:00
parent 201fe45edc
commit 85d2fdcdd7
4 changed files with 18 additions and 5 deletions

View File

@ -81,7 +81,7 @@ query."
:type '(repeat (plist)) :type '(repeat (plist))
:group 'mu4e-bookmarks) :group 'mu4e-bookmarks)
(defun mu4e-ask-bookmark (prompt) (defun mu4e-ask-bookmark (prompt)
"Ask user for bookmark using PROMPT. "Ask user for bookmark using PROMPT.
Return the corresponding query. The bookmark are as defined in Return the corresponding query. The bookmark are as defined in
@ -96,7 +96,9 @@ Return the corresponding query. The bookmark are as defined in
(propertize (make-string 1 (plist-get bm :key)) (propertize (make-string 1 (plist-get bm :key))
'face 'mu4e-highlight-face) 'face 'mu4e-highlight-face)
"]" "]"
(plist-get bm :name))) (mu4e-bookmarks) ", ")) (plist-get bm :name)))
(mu4e-filter-single-key (mu4e-bookmarks))
", "))
(kar (read-char (concat prompt bmarks)))) (kar (read-char (concat prompt bmarks))))
(mu4e-get-bookmark-query kar))) (mu4e-get-bookmark-query kar)))

View File

@ -280,8 +280,9 @@ from all maildirs under `mu4e-maildir'."
(if (not (mu4e-maildir-shortcuts)) (if (not (mu4e-maildir-shortcuts))
(substring-no-properties (substring-no-properties
(funcall mu4e-completing-read-function prompt (mu4e-get-maildirs))) (funcall mu4e-completing-read-function prompt (mu4e-get-maildirs)))
(let* ((mlist (append (mu4e-maildir-shortcuts) (let* ((mlist (append
'((:maildir "ther" :key ?o)))) (mu4e-filter-single-key (mu4e-maildir-shortcuts))
'((:maildir "ther" :key ?o))))
(fnames (fnames
(mapconcat (mapconcat
(lambda (item) (lambda (item)

View File

@ -212,6 +212,13 @@ Function returns the cdr of the list element."
(cdr chosen) (cdr chosen)
(mu4e-warn "Unknown shortcut '%c'" response)))) (mu4e-warn "Unknown shortcut '%c'" response))))
(defun mu4e-filter-single-key (lst)
"Return a list consisting of LST items with a `characterp' :key prop."
;; This works for bookmarks and maildirs.
(seq-filter (lambda (item)
(characterp (plist-get item :key)))
lst))
;;; Logging / debugging ;;; Logging / debugging

View File

@ -216,7 +216,10 @@ character of the keyboard shortcut
'help-echo query))) 'help-echo query)))
(format "%s%s\n" (format "%s%s\n"
(make-string (- max-length (string-width name)) ?\s) (make-string (- max-length (string-width name)) ?\s)
(mu4e--query-item-display-counts item)))))) data "")) (mu4e--query-item-display-counts item))))))
;; only item which have a single-character :key
(mu4e-filter-single-key data)
""))
(defun mu4e--key-val (key val &optional unit) (defun mu4e--key-val (key val &optional unit)
"Show a KEY / VAL pair, with optional UNIT." "Show a KEY / VAL pair, with optional UNIT."