12

To attach one file when in message-mode (e.g. when posting from Gnus), one does C-c C-a. What's the recommended way for attaching multiple files ?

Repeating C-c C-a can become tiresome after a while, because it asks three questions everytime.

YoungFrog
  • 3,496
  • 15
  • 27
  • There are two common approaches: (1) obtain a list of files and loop down the list -- e.g., `mapcar` -- and attach once per element; or, (2) create a loop that automatically prompts yes/no to attach another, and no breaks the loop. I prefer the file list approach, and I use a real tree-view file manager for Emacs (to simultaneously select marked files in multiple directories to be attached); however, that requires advanced `elisp` modifications. Most people stick to `dired-mode` and `dired-get-marked-files` and there is a way to operate upon multiple open `dired-mode` buffers. – lawlist Aug 06 '15 at 15:53
  • @lawlist Thanks. I'd like a file list approach indeed. I obviously don't want to write a lisp loop every time so my aim is to have a command. I'm not sure yet what the interface should look like. I'll think a bit more about and write code it if no ready-made solutions exists. – YoungFrog Aug 07 '15 at 17:36

2 Answers2

20

Open the directory in dired with C-x 4 d and type M-x turn-on-gnus-dired-mode. Then mark the required files with m (or whatever) and type C-c RET C-a. The files can now be attached to an already opened message buffer or assigned to a new one.

Dieter.Wilhelm
  • 1,836
  • 14
  • 25
-1

Attach a file in Emacs is basically just insert a chunk of string containing file paths, you can use yasnippet to create chunks for you.

Here are the steps:

  • in shell, use find/ls to create the files list to attach

  • use cli clip tool (putclip on cygwin, pbpaste on Mac, xsel/xclip on linux) to transfer the files list to the yasnippet

chen bin
  • 4,781
  • 18
  • 36