diff options
| author | Stefan Monnier | 2008-04-23 18:37:50 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2008-04-23 18:37:50 +0000 |
| commit | e8a5fe3ed8b0feec2609d70c2ea156a4b06d68b6 (patch) | |
| tree | a80909cb13609ca80b7f0ec4ec34225132670a60 | |
| parent | dbd50d4b777798eedb485df334b0876fa4ce7354 (diff) | |
| download | emacs-e8a5fe3ed8b0feec2609d70c2ea156a4b06d68b6.tar.gz emacs-e8a5fe3ed8b0feec2609d70c2ea156a4b06d68b6.zip | |
(read-file-name): Don't let-bind default-directory.
Only abbreviate default-filename if it's a file.
| -rw-r--r-- | lisp/ChangeLog | 3 | ||||
| -rw-r--r-- | lisp/minibuffer.el | 21 |
2 files changed, 18 insertions, 6 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index a50ef0cf512..9f4da1f394a 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,8 @@ | |||
| 1 | 2008-04-23 Stefan Monnier <monnier@iro.umontreal.ca> | 1 | 2008-04-23 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 2 | ||
| 3 | * minibuffer.el (read-file-name): Don't let-bind default-directory. | ||
| 4 | Only abbreviate default-filename if it's a file. | ||
| 5 | |||
| 3 | * minibuffer.el (read-file-name-function, read-file-name-predicate) | 6 | * minibuffer.el (read-file-name-function, read-file-name-predicate) |
| 4 | (read-file-name-completion-ignore-case, insert-default-directory): | 7 | (read-file-name-completion-ignore-case, insert-default-directory): |
| 5 | New vars, moved from fileio.c. | 8 | New vars, moved from fileio.c. |
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 3651aa439bd..6cef906475e 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el | |||
| @@ -834,7 +834,8 @@ and `read-file-name-function'." | |||
| 834 | ;; If dir starts with user's homedir, change that to ~. | 834 | ;; If dir starts with user's homedir, change that to ~. |
| 835 | (setq dir (abbreviate-file-name dir)) | 835 | (setq dir (abbreviate-file-name dir)) |
| 836 | ;; Likewise for default-filename. | 836 | ;; Likewise for default-filename. |
| 837 | (setq default-filename (abbreviate-file-name default-filename)) | 837 | (if default-filename |
| 838 | (setq default-filename (abbreviate-file-name default-filename))) | ||
| 838 | (let ((insdef (cond | 839 | (let ((insdef (cond |
| 839 | ((and insert-default-directory (stringp dir)) | 840 | ((and insert-default-directory (stringp dir)) |
| 840 | (if initial | 841 | (if initial |
| @@ -846,17 +847,25 @@ and `read-file-name-function'." | |||
| 846 | (if read-file-name-function | 847 | (if read-file-name-function |
| 847 | (funcall read-file-name-function | 848 | (funcall read-file-name-function |
| 848 | prompt dir default-filename mustmatch initial predicate) | 849 | prompt dir default-filename mustmatch initial predicate) |
| 849 | (let ((default-directory (file-name-as-directory (expand-file-name dir))) | 850 | (let ((completion-ignore-case read-file-name-completion-ignore-case) |
| 850 | (completion-ignore-case read-file-name-completion-ignore-case) | ||
| 851 | (minibuffer-completing-file-name t) | 851 | (minibuffer-completing-file-name t) |
| 852 | (read-file-name-predicate (or predicate 'file-exists-p)) | 852 | (read-file-name-predicate (or predicate 'file-exists-p)) |
| 853 | (add-to-history nil)) | 853 | (add-to-history nil)) |
| 854 | 854 | ||
| 855 | (let* ((val | 855 | (let* ((val |
| 856 | (if (not (next-read-file-uses-dialog-p)) | 856 | (if (not (next-read-file-uses-dialog-p)) |
| 857 | (completing-read prompt 'read-file-name-internal | 857 | ;; We used to pass `dir' to `read-file-name-internal' by |
| 858 | nil mustmatch insdef 'file-name-history | 858 | ;; abusing the `predicate' argument. It's better to |
| 859 | default-filename) | 859 | ;; just use `default-directory', but in order to avoid |
| 860 | ;; changing `default-directory' in the current buffer, | ||
| 861 | ;; we don't let-bind it. | ||
| 862 | (lexical-let ((dir (file-name-as-directory | ||
| 863 | (expand-file-name dir)))) | ||
| 864 | (minibuffer-with-setup-hook | ||
| 865 | (lambda () (setq default-directory dir)) | ||
| 866 | (completing-read prompt 'read-file-name-internal | ||
| 867 | nil mustmatch insdef 'file-name-history | ||
| 868 | default-filename))) | ||
| 860 | ;; If DIR contains a file name, split it. | 869 | ;; If DIR contains a file name, split it. |
| 861 | (let ((file (file-name-nondirectory dir))) | 870 | (let ((file (file-name-nondirectory dir))) |
| 862 | (when (and default-filename (not (zerop (length file)))) | 871 | (when (and default-filename (not (zerop (length file)))) |