1

Using the mu4e email package, I can save attachments via A S (save multi). However, this requires that I specify the location for each attachment separately. How can I configure this so that I only have to specify the location once, and all attachments will then be saved there without my needing to pick the same location for each file?

3 Answers 3

1

Maybe you can try auto-answer.

I don't use mu4e, so the following snippet is just a pseudo-code.

(defun my/mu4e-save-all-attachments (fpath)
  (interactive "D")
  (let ((auto-answer '(("<prompt-regex>" fpath))
    (<mu4e-save-attachement>)))

Each prompt from mu4e will be answered by the first prompted fpath.

1

Update

As of 2021 09 10, Save Multi is no longer available. Mu4e has optional support for helm, and that is currently the only way to select multiple attachments to be saved at once. This is fine if you use helm, but if you don't, it doesn't leave you with a very satisfactory approach.

One way to deal with this is to turn on helm mode, but only for this feature. I do that with advice:

(defun tws-mu4e-save-all-fix (orig-fun &rest args)
  "Temporarily turn on helm-mode for selecting files."
  (helm-mode)
  (apply orig-fun args)
  (helm-mode -1))

(advice-add 'mu4e-view-save-attachments :around #'tws-mu4e-save-all-fix)

With this feature, you will use the helm interface to select files, and that allows you to select all files via M-a.

Other approaches are found here.

Original Answer (no longer relevant)

It turns out this feature is supported by the customization option Mu4e Save Multiple Attachments Without Asking:

If non-nil, saving multiple attachments asks once for a Hide directory and saves all attachments in the chosen directory.

1

Doom 3.0.0-pre; Emacs 29.1; MacOS 13 (w/M1 processor)

In Doom Emacs* using vertico+embark, it turns out this is relatively straight-forward (though not documented in the mu4e documentation as far as I'm aware as of Jan 2024)

  1. invoke mu4e-view-save-attachments (default EVIL keybinding: p when reading the message in 'message view'). You will be presented a list of the message's attachments.
  2. Before selecting any, run M-x embark-act-all.
    1. this function prompts the user for an action and runs it on all candidates. So we're going to select any one of the attachments to save, and that action will be applied to all the attachments.
    2. Note that in doom the Space leader key isn't available at this point so invoke it via Meta-x and typing embark-act-all).
    3. Hit enter (which selects the first attachment. really you can select any of them but hitting enter is just quicker)
  3. You'll then be prompted with Run mu4e-view-save-attachments on "X" nils? (y or n) (where "X" is the number of attachments available). Hit y to confirm.

It sounds complicated but after you do it a few times it starts to become muscle memory. Plus embark-act-all will be at the top of your M-x actions list, so you'll be reminded of its name there too.

Credit for this goes to https://www.reddit.com/r/emacs/comments/p7gvf9/mu4e_how_best_to_save_large_numbers_of/.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.