From c4aba242a30c30812f327aa3f4bf86534fb3f912 Mon Sep 17 00:00:00 2001 From: TEC Date: Sat, 11 Sep 2021 22:07:39 +0800 Subject: [PATCH] feat(mu4e): improve part selection experience It's not nice having to think of the index of the MIME part you want to look at, it's much nicer to get a completing read with information about those parts. --- modules/email/mu4e/config.el | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/modules/email/mu4e/config.el b/modules/email/mu4e/config.el index 7b75112d7..ae4edb589 100644 --- a/modules/email/mu4e/config.el +++ b/modules/email/mu4e/config.el @@ -202,8 +202,25 @@ Acts like a singular `mu4e-view-save-attachments', without the saving." (mu4e~view-open-file (mu4e~view-mime-part-to-temp-file (cdr (+mu4e-select-attachment))))) + (defun +mu4e-select-part () + (let ((parts (mu4e~view-gather-mime-parts)) labeledparts) + (dolist (part parts) + (push (cons (concat (propertize (format "%-2s " (car part)) 'face '(bold font-lock-type-face)) + (or (cdr (assoc 'filename (assoc "attachment" (cdr part)))) + (propertize "unnamed" 'face '(italic font-lock-doc-face))) + (propertize (format " [%s]" (caaddr part)) 'face 'font-lock-constant-face)) + part) + labeledparts)) + (cdr (assoc (completing-read "Select part: " (mapcar #'car labeledparts)) + labeledparts)))) + + (defun +mu4e-view-select-mime-part-action () + "Select a MIME part, and perform an action on it." + (interactive) + (mu4e-view-mime-part-action (car (+mu4e-select-part)))) + (map! :map mu4e-view-mode-map - :ne "A" #'mu4e-view-mime-part-action + :ne "A" #'+mu4e-view-select-mime-part-action :ne "p" #'mu4e-view-save-attachments :ne "o" #'+mu4e-open-attachment))