Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Better dialog to save attachments. #326

Merged
merged 1 commit into from

2 participants

@DamienCassou

This commit replaces the call to read-directory-name' by a call to
read-file-name' when asking the user about the target location for
saving an attachment. This new dialog is better suited because:

1/ the user is currently saving a file, not a directory: he might want
to complete over existing files (e.g., to replace an existing file
with a new one just received).

2/ the current dialog was asking for a directory but then, if the user
enters a directory, mu4e proposes him to "override" the directory
with a file. This is not going to work obviously. In the new dialog,
it is also possible to enter a directory name instead of a file name.
In this case, a new file is created under the chosen directory name.

@DamienCassou DamienCassou Better dialog to save attachments.
This commit replaces the call to `read-directory-name' by a call to
`read-file-name' when asking the user about the target location for
saving an attachment. This new dialog is better suited because:

1/ the user is currently saving a file, not a directory: he might want
   to complete over existing files (e.g., to replace an existing file
   with a new one just received).

2/ the current dialog was asking for a directory but then, if the user
   enters a directory, mu4e proposes him to "override" the directory
   with a file. This is not going to work obviously. In the new dialog,
   it is also possible to enter a directory name instead of a file name.
   In this case, a new file is created under the chosen directory name.
6e790ba
@djcb djcb merged commit f859c44 into from
@djcb
Owner

merged, thanks!

@DamienCassou DamienCassou deleted the branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 10, 2013
  1. @DamienCassou

    Better dialog to save attachments.

    DamienCassou authored
    This commit replaces the call to `read-directory-name' by a call to
    `read-file-name' when asking the user about the target location for
    saving an attachment. This new dialog is better suited because:
    
    1/ the user is currently saving a file, not a directory: he might want
       to complete over existing files (e.g., to replace an existing file
       with a new one just received).
    
    2/ the current dialog was asking for a directory but then, if the user
       enters a directory, mu4e proposes him to "override" the directory
       with a file. This is not going to work obviously. In the new dialog,
       it is also possible to enter a directory name instead of a file name.
       In this case, a new file is created under the chosen directory name.
This page is out of date. Refresh to see the latest.
Showing with 15 additions and 3 deletions.
  1. +15 −3 mu4e/mu4e-view.el
View
18 mu4e/mu4e-view.el
@@ -905,15 +905,27 @@ If ATTNUM is nil ask for the attachment number."
(index (plist-get att :index))
(retry t) (fpath))
(while retry
- (setq fpath (expand-file-name
- (read-directory-name
- (mu4e-format "Save as ") path nil nil fname)))
+ (setq fpath (mu4e-view-request-attachment-path fname path))
(setq retry
(and (file-exists-p fpath)
(not (y-or-n-p (mu4e-format "Overwrite '%s'?" fpath))))))
(mu4e~proc-extract
'save (mu4e-message-field msg :docid) index fpath)))
+(defun mu4e-view-request-attachment-path (fname path)
+ "Ask the user where to save FNAME (default is PATH/FNAME)."
+ (let ((fpath (expand-file-name
+ (read-file-name
+ (mu4e-format "Save as ")
+ path
+ nil
+ nil
+ fname)
+ path)))
+ (if (file-directory-p fpath)
+ (expand-file-name fname fpath)
+ fpath)))
+
(defun mu4e-view-save-attachment-multi (&optional msg)
"Offer to save multiple email attachments from the current message.
Default is to save all messages, [1..n], where n is the number of
Something went wrong with that request. Please try again.