Mercurial > emacs
changeset 94301:9060af7294b9
(read-file-name): Don't let-bind default-directory.
Only abbreviate default-filename if it's a file.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Wed, 23 Apr 2008 18:37:50 +0000 |
parents | b47239d57d36 |
children | 5a4d9f3d23f9 |
files | lisp/ChangeLog lisp/minibuffer.el |
diffstat | 2 files changed, 18 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/ChangeLog Wed Apr 23 18:19:57 2008 +0000 +++ b/lisp/ChangeLog Wed Apr 23 18:37:50 2008 +0000 @@ -1,5 +1,8 @@ 2008-04-23 Stefan Monnier <monnier@iro.umontreal.ca> + * minibuffer.el (read-file-name): Don't let-bind default-directory. + Only abbreviate default-filename if it's a file. + * minibuffer.el (read-file-name-function, read-file-name-predicate) (read-file-name-completion-ignore-case, insert-default-directory): New vars, moved from fileio.c.
--- a/lisp/minibuffer.el Wed Apr 23 18:19:57 2008 +0000 +++ b/lisp/minibuffer.el Wed Apr 23 18:37:50 2008 +0000 @@ -834,7 +834,8 @@ ;; If dir starts with user's homedir, change that to ~. (setq dir (abbreviate-file-name dir)) ;; Likewise for default-filename. - (setq default-filename (abbreviate-file-name default-filename)) + (if default-filename + (setq default-filename (abbreviate-file-name default-filename))) (let ((insdef (cond ((and insert-default-directory (stringp dir)) (if initial @@ -846,17 +847,25 @@ (if read-file-name-function (funcall read-file-name-function prompt dir default-filename mustmatch initial predicate) - (let ((default-directory (file-name-as-directory (expand-file-name dir))) - (completion-ignore-case read-file-name-completion-ignore-case) + (let ((completion-ignore-case read-file-name-completion-ignore-case) (minibuffer-completing-file-name t) (read-file-name-predicate (or predicate 'file-exists-p)) (add-to-history nil)) (let* ((val (if (not (next-read-file-uses-dialog-p)) - (completing-read prompt 'read-file-name-internal - nil mustmatch insdef 'file-name-history - default-filename) + ;; We used to pass `dir' to `read-file-name-internal' by + ;; abusing the `predicate' argument. It's better to + ;; just use `default-directory', but in order to avoid + ;; changing `default-directory' in the current buffer, + ;; we don't let-bind it. + (lexical-let ((dir (file-name-as-directory + (expand-file-name dir)))) + (minibuffer-with-setup-hook + (lambda () (setq default-directory dir)) + (completing-read prompt 'read-file-name-internal + nil mustmatch insdef 'file-name-history + default-filename))) ;; If DIR contains a file name, split it. (let ((file (file-name-nondirectory dir))) (when (and default-filename (not (zerop (length file))))