From: Stefan Monnier Date: Thu, 16 Jan 2020 15:18:15 +0000 (-0500) Subject: * lisp/minibuffer.el (read-file-name-default): Fix bug#39057 X-Git-Tag: emacs-27.0.90~153 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=52080b5778cbe535c331fa14539aecd88f2be0a0;p=emacs.git * lisp/minibuffer.el (read-file-name-default): Fix bug#39057 --- diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index a8b2a984c52..4831bf72e9d 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -2737,8 +2737,13 @@ See `read-file-name' for the meaning of the arguments." (unless dir (setq dir (or default-directory "~/"))) (unless (file-name-absolute-p dir) (setq dir (expand-file-name dir))) (unless default-filename - (setq default-filename (if initial (expand-file-name initial dir) - buffer-file-name))) + (setq default-filename + (cond + ((null initial) buffer-file-name) + ;; Special-case "" because (expand-file-name "" "/tmp/") returns + ;; "/tmp" rather than "/tmp/" (bug#39057). + ((equal "" initial) dir) + (t (expand-file-name initial dir))))) ;; If dir starts with user's homedir, change that to ~. (setq dir (abbreviate-file-name dir)) ;; Likewise for default-filename.