From dc39b96aae823fc9ee3d4dd50ce4160f00e504f2 Mon Sep 17 00:00:00 2001 From: Christopher Schmidt Date: Wed, 30 Jan 2013 09:44:46 +0000 Subject: [PATCH] lisp/gnus/mm-decode.el (mm-save-part): Handle invalid read-file-name results --- lisp/gnus/ChangeLog | 4 ++++ lisp/gnus/mm-decode.el | 28 ++++++++++++++++++++-------- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog index 745e0ede5a8..f224752a334 100644 --- a/lisp/gnus/ChangeLog +++ b/lisp/gnus/ChangeLog @@ -1,3 +1,7 @@ +2013-01-30 Christopher Schmidt + + * mm-decode.el (mm-save-part): Handle invalid read-file-name results. + 2013-01-21 Lars Magne Ingebrigtsen * gnus-sum.el (gnus-summary-read-group-1): Protect against not being diff --git a/lisp/gnus/mm-decode.el b/lisp/gnus/mm-decode.el index b5e4d3e38e8..812ee7396dd 100644 --- a/lisp/gnus/mm-decode.el +++ b/lisp/gnus/mm-decode.el @@ -1298,14 +1298,26 @@ PROMPT overrides the default one used to ask user for a file name." (when filename (setq filename (gnus-map-function mm-file-name-rewrite-functions (file-name-nondirectory filename)))) - (setq file - (read-file-name - (or prompt - (format "Save MIME part to (default %s): " - (or filename ""))) - (or mm-default-directory default-directory) - (expand-file-name (or filename "") - (or mm-default-directory default-directory)))) + (while + (progn + (setq file + (read-file-name + (or prompt + (format "Save MIME part to (default %s): " + (or filename ""))) + (or mm-default-directory default-directory) + (expand-file-name (or filename "") + (or mm-default-directory default-directory)))) + (cond ((or (not file) (equal file "")) + (message "Please enter a file name") + t) + ((and (file-directory-p file) + (not filename)) + (message "Please enter a non-directory file name") + t) + (t nil))) + (sit-for 2) + (discard-input)) (if (file-directory-p file) (setq file (expand-file-name filename file)) (setq file (expand-file-name -- 2.11.4.GIT