summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/mu4e-attachments.el8
-rw-r--r--tests/test-mu4e-attachments.el6
2 files changed, 12 insertions, 2 deletions
diff --git a/modules/mu4e-attachments.el b/modules/mu4e-attachments.el
index 8f711000..4acdfd6a 100644
--- a/modules/mu4e-attachments.el
+++ b/modules/mu4e-attachments.el
@@ -208,7 +208,10 @@ The result is an alist of display labels to MIME part plists."
(cj/mu4e--attachment-selection-render))
(defun cj/mu4e-attachment-selection-save-marked ()
- "Save marked attachments from the selection buffer."
+ "Save the marked attachments, then clear the marks.
+Clearing the marks keeps a second `s' from silently re-saving the same set;
+quit the buffer with `q' or RET when done. With no marks set, this is a
+`user-error'."
(interactive)
(let ((parts (mapcar (lambda (entry) (plist-get entry :part))
(seq-filter (lambda (entry)
@@ -218,6 +221,9 @@ The result is an alist of display labels to MIME part plists."
(user-error "No attachments selected"))
(let ((paths (cj/mu4e--save-attachment-parts
parts cj/mu4e-attachment-selection-directory)))
+ (dolist (entry cj/mu4e-attachment-selection-entries)
+ (setf (plist-get entry :selected) nil))
+ (cj/mu4e--attachment-selection-render)
(message "Saved %d attachment%s to %s"
(length paths)
(if (= (length paths) 1) "" "s")
diff --git a/tests/test-mu4e-attachments.el b/tests/test-mu4e-attachments.el
index 3105d710..21336f75 100644
--- a/tests/test-mu4e-attachments.el
+++ b/tests/test-mu4e-attachments.el
@@ -192,7 +192,11 @@ so this fails the same way whether or not mu4e's MIME support is loadable."
((symbol-function 'message) (lambda (&rest _) nil)))
(should (equal (cj/mu4e-attachment-selection-save-marked)
'("/downloads/b.pdf")))
- (should (equal saved (list (list b) "/downloads/")))))
+ (should (equal saved (list (list b) "/downloads/")))
+ ;; marks clear after a successful save so `s' won't re-save them
+ (should-not (seq-some (lambda (entry) (plist-get entry :selected))
+ cj/mu4e-attachment-selection-entries))
+ (should (string-match-p "\\[ \\] b\\.pdf" (buffer-string)))))
(kill-buffer buffer))))
(ert-deftest test-mu4e-attachments-selection-save-marked-errors-when-empty ()