Skip to content

Commit

Permalink
mu4e-mime-parts: don't try to open non-files
Browse files Browse the repository at this point in the history
When completion fails, don't try to open any files in
mu4e-view-save-attachments.
  • Loading branch information
djcb committed Oct 8, 2024
1 parent f9af40a commit aa4946c
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions mu4e/mu4e-mime-parts.el
Original file line number Diff line number Diff line change
Expand Up @@ -297,13 +297,13 @@ does not have this limitation."
(interactive "P")
(let* ((parts (mu4e-view-mime-parts))
(candidates (seq-map
(lambda (fpart)
(cons ;; (filename . annotation)
(plist-get fpart :filename)
fpart))
(seq-filter
(lambda (part) (plist-get part :attachment-like))
parts)))
(lambda (fpart)
(cons ;; (filename . annotation)
(plist-get fpart :filename)
fpart))
(seq-filter
(lambda (part) (plist-get part :attachment-like))
parts)))
(candidates (or candidates
(mu4e-warn "No attachments for this message")))
(files (mu4e--completing-read "Save file(s): " candidates
Expand All @@ -316,8 +316,10 @@ does not have this limitation."
(path (mu4e--uniqify-file-name
(mu4e-join-paths
(or custom-dir (plist-get part :target-dir))
(plist-get part :filename)))))
(mm-save-part-to-file (plist-get part :handle) path)))
(plist-get part :filename))))
(handle (plist-get part :handle)))
(when handle ;; completion may fail, and then there's no handle.
(mm-save-part-to-file handle path))))
files)))

(defvar mu4e-view-mime-part-actions
Expand Down

0 comments on commit aa4946c

Please sign in to comment.