feat(mu4e): reimplement attachment opening command
This can be done via 'a', but it's a nice convenience to have, particularly as it filters out non-attachment MIME parts. Closes #5027.
This commit is contained in:
parent
47be8e292e
commit
251705149b
1 changed files with 21 additions and 1 deletions
|
@ -183,9 +183,29 @@
|
||||||
|
|
||||||
;; Functionality otherwise obscured in mu4e 1.6
|
;; Functionality otherwise obscured in mu4e 1.6
|
||||||
(when (version<= "1.6" mu4e-mu-version)
|
(when (version<= "1.6" mu4e-mu-version)
|
||||||
|
(defun +mu4e-select-attachment ()
|
||||||
|
"Use completing-read to select a single attachment.
|
||||||
|
Acts like a singular `mu4e-view-save-attachments', without the saving."
|
||||||
|
(let ((parts (mu4e~view-gather-mime-parts)) files)
|
||||||
|
(dolist (part parts)
|
||||||
|
(let ((fname (cdr (assoc 'filename (assoc "attachment" (cdr part))))))
|
||||||
|
(when fname
|
||||||
|
(push (cons fname part) files))))
|
||||||
|
(if files
|
||||||
|
(cdr (assoc (completing-read "Select attachment: " (mapcar #'car files))
|
||||||
|
files))
|
||||||
|
(user-error (mu4e-format "No attached files found")))))
|
||||||
|
|
||||||
|
(defun +mu4e-open-attachment ()
|
||||||
|
"Select an attachment, and open it."
|
||||||
|
(interactive)
|
||||||
|
(mu4e~view-open-file
|
||||||
|
(mu4e~view-mime-part-to-temp-file (cdr (+mu4e-select-attachment)))))
|
||||||
|
|
||||||
(map! :map mu4e-view-mode-map
|
(map! :map mu4e-view-mode-map
|
||||||
:ne "A" #'mu4e-view-mime-part-action
|
:ne "A" #'mu4e-view-mime-part-action
|
||||||
:ne "p" #'mu4e-view-save-attachments))
|
:ne "p" #'mu4e-view-save-attachments
|
||||||
|
:ne "o" #'+mu4e-open-attachment))
|
||||||
|
|
||||||
(map! :localleader
|
(map! :localleader
|
||||||
:map mu4e-compose-mode-map
|
:map mu4e-compose-mode-map
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue