From 330b50982d0eadf27f08a857ae98022c0606b42e Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Fri, 2 May 2008 17:20:07 +0000 Subject: [PATCH] (dired-read-dir-and-switches): Set minibuffer-completing-file-name and call substitute-in-file-name. --- lisp/ChangeLog | 3 +++ lisp/dired.el | 73 ++++++++++++++++++++++++++------------------------ 2 files changed, 41 insertions(+), 35 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 1aef1c8d701..f79c5fc850b 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,8 @@ 2008-05-02 Stefan Monnier + * dired.el (dired-read-dir-and-switches): + Set minibuffer-completing-file-name and call substitute-in-file-name. + * minibuffer.el (completion-hilit-commonality): Revert last change: the leftover code was actually useful. diff --git a/lisp/dired.el b/lisp/dired.el index b301bda7e6b..a2f0f009d33 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -589,41 +589,44 @@ Don't use that together with FILTER." (defun dired-read-dir-and-switches (str) ;; For use in interactive. - (reverse (list - (if current-prefix-arg - (read-string "Dired listing switches: " - dired-listing-switches)) - ;; 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. - (if (next-read-file-uses-dialog-p) - (read-directory-name (format "Dired %s(directory): " str) - 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))))))) + (reverse + (list + (if current-prefix-arg + (read-string "Dired listing switches: " + dired-listing-switches)) + ;; 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. + (if (next-read-file-uses-dialog-p) + (read-directory-name (format "Dired %s(directory): " str) + 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 minibuffer-completing-file-name t) + (setq default-directory defdir)) + (substitute-in-file-name + (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 -- 2.39.5