1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-28 07:45:00 +00:00

(dired-read-dir-and-switches):

Set minibuffer-completing-file-name and call substitute-in-file-name.
This commit is contained in:
Stefan Monnier 2008-05-02 17:20:07 +00:00
parent 457d37ba22
commit 330b50982d
2 changed files with 41 additions and 35 deletions

View File

@ -1,5 +1,8 @@
2008-05-02 Stefan Monnier <monnier@iro.umontreal.ca> 2008-05-02 Stefan Monnier <monnier@iro.umontreal.ca>
* 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: * minibuffer.el (completion-hilit-commonality): Revert last change:
the leftover code was actually useful. the leftover code was actually useful.

View File

@ -589,41 +589,44 @@ Don't use that together with FILTER."
(defun dired-read-dir-and-switches (str) (defun dired-read-dir-and-switches (str)
;; For use in interactive. ;; For use in interactive.
(reverse (list (reverse
(if current-prefix-arg (list
(read-string "Dired listing switches: " (if current-prefix-arg
dired-listing-switches)) (read-string "Dired listing switches: "
;; If a dialog is about to be used, call read-directory-name so dired-listing-switches))
;; the dialog code knows we want directories. Some dialogs can ;; If a dialog is about to be used, call read-directory-name so
;; only select directories or files when popped up, not both. ;; the dialog code knows we want directories. Some dialogs can
(if (next-read-file-uses-dialog-p) ;; only select directories or files when popped up, not both.
(read-directory-name (format "Dired %s(directory): " str) (if (next-read-file-uses-dialog-p)
nil default-directory nil) (read-directory-name (format "Dired %s(directory): " str)
(lexical-let ((default (and buffer-file-name nil default-directory nil)
(abbreviate-file-name buffer-file-name))) (lexical-let ((default (and buffer-file-name
(defdir default-directory)) (abbreviate-file-name buffer-file-name)))
(minibuffer-with-setup-hook (defdir default-directory))
(lambda () (minibuffer-with-setup-hook
(setq minibuffer-default default) (lambda ()
(setq default-directory defdir)) (setq minibuffer-default default)
(completing-read (setq minibuffer-completing-file-name t)
(format "Dired %s(directory): " str) (setq default-directory defdir))
;; We need a mix of read-file-name and read-directory-name (substitute-in-file-name
;; so that completion to directories is preferred, but if (completing-read
;; the user wants to enter a global pattern, he can still (format "Dired %s(directory): " str)
;; use completion on filenames to help him write the pattern. ;; We need a mix of read-file-name and read-directory-name
;; Essentially, we want to use ;; so that completion to directories is preferred, but if
;; (completion-table-with-predicate ;; the user wants to enter a global pattern, he can still
;; 'read-file-name-internal 'file-directory-p nil) ;; use completion on filenames to help him write the pattern.
;; but that doesn't work because read-file-name-internal ;; Essentially, we want to use
;; does not obey its `predicate' argument. ;; (completion-table-with-predicate
(completion-table-in-turn ;; 'read-file-name-internal 'file-directory-p nil)
(lambda (str pred action) ;; but that doesn't work because read-file-name-internal
(let ((read-file-name-predicate 'file-directory-p)) ;; does not obey its `predicate' argument.
(complete-with-action (completion-table-in-turn
action 'read-file-name-internal str nil))) (lambda (str pred action)
'read-file-name-internal) (let ((read-file-name-predicate 'file-directory-p))
nil nil (abbreviate-file-name defdir) 'file-name-history))))))) (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 (define-key ctl-x-map "d" 'dired)
;;;###autoload ;;;###autoload