From edd47ced712f14feb889dafe4428391dde917b56 Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Mon, 6 Apr 2020 20:47:29 +0300 Subject: [PATCH] mu4e: use mu4e-attachment-dir for attaching, too Use mu4e-attachment-dir also for attaching (and not just for extracting) attachments; the default (current draft message dir) is not very useful. --- NEWS.org | 5 ++++- mu4e/mu4e-compose.el | 5 +++++ mu4e/mu4e-vars.el | 9 +++++++-- mu4e/mu4e.texi | 6 +++--- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/NEWS.org b/NEWS.org index 7b1575b7..78c6b07c 100644 --- a/NEWS.org +++ b/NEWS.org @@ -93,7 +93,10 @@ ~plist~ to ~t~. For speed-reasons, these counts do _not_ filter out duplicates or messages that have been removed from the filesystem behind mu4e's back. - - The mu4e <-> mu intreaction has been rewritten to communicate using + - ~mu4e-attachment-dir~ now also applies to composing messages; it determines + the default directory for inclusion. + + - The mu4e <-> mu interaction has been rewritten to communicate using s-expressions, with a repl for testing. If you have readline installed, you also get history. diff --git a/mu4e/mu4e-compose.el b/mu4e/mu4e-compose.el index e642be7f..47697e4a 100644 --- a/mu4e/mu4e-compose.el +++ b/mu4e/mu4e-compose.el @@ -477,6 +477,11 @@ buffers; lets remap its faces so it uses the ones for mu4e." (visual-line-mode t)) (setq mml-enable-flowed nil)) + ;; set the attachment dir to something more reasonable than the draft + ;; directory. + (setq default-directory (mu4e~get-attachment-dir)) + + (let ((keymap (lookup-key message-mode-map [menu-bar text]))) (when keymap (define-key-after diff --git a/mu4e/mu4e-vars.el b/mu4e/mu4e-vars.el index e2dfe959..454e7793 100644 --- a/mu4e/mu4e-vars.el +++ b/mu4e/mu4e-vars.el @@ -167,10 +167,15 @@ better with e.g. offlineimap." :safe 'booleanp) (defcustom mu4e-attachment-dir (expand-file-name "~/") - "Default directory for saving attachments. + "Default directory for attaching and saving attachments. + This can be either a string (a file system path), or a function that takes a filename and the mime-type as arguments, and returns -the attachment dir. See Info node `(mu4e) Attachments' for details." +the attachment dir. See Info node `(mu4e) Attachments' for +details. + +When this called for composing a message, both filename and +mime-type are nill." :type 'directory :group 'mu4e :safe 'stringp) diff --git a/mu4e/mu4e.texi b/mu4e/mu4e.texi index 04831d01..3b36298b 100644 --- a/mu4e/mu4e.texi +++ b/mu4e/mu4e.texi @@ -1340,9 +1340,9 @@ OS X) the @t{open} program for opening attachments. If you want to use another program, you do so by setting the @t{MU_PLAY_PROGRAM} environment variable to the program to be used. -The default directory for extracting (saving) attachments is your home -directory (@file{~/}); you can change this using the variable -@code{mu4e-attachment-dir}, for example: +The default directory for attaching and extracting (saving) +attachmentsis your home directory (@file{~/}); you can change this +using the variable @code{mu4e-attachment-dir}, for example: @lisp (setq mu4e-attachment-dir "~/Downloads")