summaryrefslogtreecommitdiff
path: root/lisp/dired.el
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2008-04-29 14:48:57 +0000
committerStefan Monnier <monnier@iro.umontreal.ca>2008-04-29 14:48:57 +0000
commitb95ced6beee4bf2afccfc5aa0670d110d6afdfa6 (patch)
tree51a1a3c70c5e5bc281e7a12c7ffef34b82494837 /lisp/dired.el
parent28bb43e10ff8e0a7f32ac32ef41a5eda5259c326 (diff)
downloademacs-b95ced6beee4bf2afccfc5aa0670d110d6afdfa6.tar.gz
(dired-read-dir-and-switches): Replace last change with
a new approach that mixes read-file-name and read-directory-name.
Diffstat (limited to 'lisp/dired.el')
-rw-r--r--lisp/dired.el32
1 files changed, 27 insertions, 5 deletions
diff --git a/lisp/dired.el b/lisp/dired.el
index 521b1769a8e..ba20ef2cc1b 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -594,12 +594,34 @@ Don't use that together with FILTER."
;; If a dialog is about to be used, call read-directory-name so
;; the dialog code knows we want directories. Some dialogs can
;; only select directories or files when popped up, not both.
- (let ((default (and buffer-file-name
- (abbreviate-file-name buffer-file-name))))
- (minibuffer-with-setup-hook
- (lambda () (setq minibuffer-default default))
+ (if (next-read-file-uses-dialog-p)
(read-directory-name (format "Dired %s(directory): " str)
- nil default-directory nil))))))
+ nil default-directory nil)
+ (lexical-let ((default (and buffer-file-name
+ (abbreviate-file-name buffer-file-name)))
+ (defdir default-directory))
+ (minibuffer-with-setup-hook
+ (lambda ()
+ (setq minibuffer-default default)
+ (setq default-directory defdir))
+ (completing-read
+ (format "Dired %s(directory): " str)
+ ;; We need a mix of read-file-name and read-directory-name
+ ;; so that completion to directories is preferred, but if
+ ;; the user wants to enter a global pattern, he can still
+ ;; use completion on filenames to help him write the pattern.
+ ;; Essentially, we want to use
+ ;; (completion-table-with-predicate
+ ;; 'read-file-name-internal 'file-directory-p nil)
+ ;; but that doesn't work because read-file-name-internal
+ ;; does not obey its `predicate' argument.
+ (completion-table-in-turn
+ (lambda (str pred action)
+ (let ((read-file-name-predicate 'file-directory-p))
+ (complete-with-action
+ action 'read-file-name-internal str nil)))
+ 'read-file-name-internal)
+ nil nil (abbreviate-file-name defdir) 'file-name-history)))))))
;;;###autoload (define-key ctl-x-map "d" 'dired)
;;;###autoload