I used to use helm and really liked mu4e-view-save-attachments as a quick way to save multiple attachments in an email at once. I recently switched to Ivy and learned this function is helm specific. Does anyone have an ivy version of this or an equally efficient method of saving multiple attachments at once?
This ugly hack almost works (just a slight modification of mu4e-view-save-attachments but I get an error
wrong-type-argument listp "whatever-attachment-filename-I-select" the error is happening in the
(member f files) function call.
(defun jds/mu4e-view-save-attachments (&optional arg) "Save mime parts from current mu4e gnus view buffer. When helm-mode is enabled provide completion on attachments and possibility to mark candidates to save, otherwise completion on attachments is done with `completing-read-multiple', in this case use \",\" to separate candidate, completion is provided after each \",\". Note, currently this does not work well with file names containing commas." (interactive "P") (cl-assert (and (eq major-mode 'mu4e-view-mode) (derived-mode-p 'gnus-article-mode))) (let* ((parts (mu4e~view-gather-mime-parts)) (handles '()) (files '()) (helm-comp-read-use-marked t) (compfn (if (and (boundp 'helm-mode) helm-mode) #'completing-read ;; Fallback to `completing-read-multiple' with poor ;; completion ;;#'completing-read-multiple #'ivy-completing-read)) dir) (dolist (part parts) (let ((fname (cdr (assoc 'filename (assoc "attachment" (cdr part)))))) (when fname (push `(,fname . ,(cdr part)) handles) (push fname files)))) (if files (progn (setq files (funcall compfn "Save part(s): " files) dir (if arg (read-directory-name "Save to directory: ") mu4e-attachment-dir)) (cl-loop for (f . h) in handles when (member f files) do (mm-save-part-to-file h (expand-file-name f dir)))) (mu4e-message "No attached files found"))))
ivy-read, and only when an action is defined; it doesn't seem to work for
ivy-completing-read. Which means you can't just swap that in as you have done, some additional work will be required.