diff options
| author | Stefan Monnier | 2008-05-02 17:20:07 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2008-05-02 17:20:07 +0000 |
| commit | 330b50982d0eadf27f08a857ae98022c0606b42e (patch) | |
| tree | 3623e062c9e34001fb0418b62bf62ea146ce66ca | |
| parent | 457d37ba2254ff454f4ddc70304b75bbe55573bb (diff) | |
| download | emacs-330b50982d0eadf27f08a857ae98022c0606b42e.tar.gz emacs-330b50982d0eadf27f08a857ae98022c0606b42e.zip | |
(dired-read-dir-and-switches):
Set minibuffer-completing-file-name and call substitute-in-file-name.
| -rw-r--r-- | lisp/ChangeLog | 3 | ||||
| -rw-r--r-- | 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 @@ | |||
| 1 | 2008-05-02 Stefan Monnier <monnier@iro.umontreal.ca> | 1 | 2008-05-02 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 2 | ||
| 3 | * dired.el (dired-read-dir-and-switches): | ||
| 4 | Set minibuffer-completing-file-name and call substitute-in-file-name. | ||
| 5 | |||
| 3 | * minibuffer.el (completion-hilit-commonality): Revert last change: | 6 | * minibuffer.el (completion-hilit-commonality): Revert last change: |
| 4 | the leftover code was actually useful. | 7 | the leftover code was actually useful. |
| 5 | 8 | ||
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." | |||
| 589 | 589 | ||
| 590 | (defun dired-read-dir-and-switches (str) | 590 | (defun dired-read-dir-and-switches (str) |
| 591 | ;; For use in interactive. | 591 | ;; For use in interactive. |
| 592 | (reverse (list | 592 | (reverse |
| 593 | (if current-prefix-arg | 593 | (list |
| 594 | (read-string "Dired listing switches: " | 594 | (if current-prefix-arg |
| 595 | dired-listing-switches)) | 595 | (read-string "Dired listing switches: " |
| 596 | ;; If a dialog is about to be used, call read-directory-name so | 596 | dired-listing-switches)) |
| 597 | ;; the dialog code knows we want directories. Some dialogs can | 597 | ;; If a dialog is about to be used, call read-directory-name so |
| 598 | ;; only select directories or files when popped up, not both. | 598 | ;; the dialog code knows we want directories. Some dialogs can |
| 599 | (if (next-read-file-uses-dialog-p) | 599 | ;; only select directories or files when popped up, not both. |
| 600 | (read-directory-name (format "Dired %s(directory): " str) | 600 | (if (next-read-file-uses-dialog-p) |
| 601 | nil default-directory nil) | 601 | (read-directory-name (format "Dired %s(directory): " str) |
| 602 | (lexical-let ((default (and buffer-file-name | 602 | nil default-directory nil) |
| 603 | (abbreviate-file-name buffer-file-name))) | 603 | (lexical-let ((default (and buffer-file-name |
| 604 | (defdir default-directory)) | 604 | (abbreviate-file-name buffer-file-name))) |
| 605 | (minibuffer-with-setup-hook | 605 | (defdir default-directory)) |
| 606 | (lambda () | 606 | (minibuffer-with-setup-hook |
| 607 | (setq minibuffer-default default) | 607 | (lambda () |
| 608 | (setq default-directory defdir)) | 608 | (setq minibuffer-default default) |
| 609 | (completing-read | 609 | (setq minibuffer-completing-file-name t) |
| 610 | (format "Dired %s(directory): " str) | 610 | (setq default-directory defdir)) |
| 611 | ;; We need a mix of read-file-name and read-directory-name | 611 | (substitute-in-file-name |
| 612 | ;; so that completion to directories is preferred, but if | 612 | (completing-read |
| 613 | ;; the user wants to enter a global pattern, he can still | 613 | (format "Dired %s(directory): " str) |
| 614 | ;; use completion on filenames to help him write the pattern. | 614 | ;; We need a mix of read-file-name and read-directory-name |
| 615 | ;; Essentially, we want to use | 615 | ;; so that completion to directories is preferred, but if |
| 616 | ;; (completion-table-with-predicate | 616 | ;; the user wants to enter a global pattern, he can still |
| 617 | ;; 'read-file-name-internal 'file-directory-p nil) | 617 | ;; use completion on filenames to help him write the pattern. |
| 618 | ;; but that doesn't work because read-file-name-internal | 618 | ;; Essentially, we want to use |
| 619 | ;; does not obey its `predicate' argument. | 619 | ;; (completion-table-with-predicate |
| 620 | (completion-table-in-turn | 620 | ;; 'read-file-name-internal 'file-directory-p nil) |
| 621 | (lambda (str pred action) | 621 | ;; but that doesn't work because read-file-name-internal |
| 622 | (let ((read-file-name-predicate 'file-directory-p)) | 622 | ;; does not obey its `predicate' argument. |
| 623 | (complete-with-action | 623 | (completion-table-in-turn |
| 624 | action 'read-file-name-internal str nil))) | 624 | (lambda (str pred action) |
| 625 | 'read-file-name-internal) | 625 | (let ((read-file-name-predicate 'file-directory-p)) |
| 626 | nil nil (abbreviate-file-name defdir) 'file-name-history))))))) | 626 | (complete-with-action |
| 627 | action 'read-file-name-internal str nil))) | ||
| 628 | 'read-file-name-internal) | ||
| 629 | nil nil (abbreviate-file-name defdir) 'file-name-history)))))))) | ||
| 627 | 630 | ||
| 628 | ;;;###autoload (define-key ctl-x-map "d" 'dired) | 631 | ;;;###autoload (define-key ctl-x-map "d" 'dired) |
| 629 | ;;;###autoload | 632 | ;;;###autoload |