diff options
| author | Stefan Monnier | 2008-05-13 08:39:54 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2008-05-13 08:39:54 +0000 |
| commit | 833e7ac3fcc6652177daf10c01e9656587df87eb (patch) | |
| tree | 375c066eacb4fe1dd1e3ed0a83108a3998a8943f | |
| parent | 44f249c0558f1dab796118fe4e95a31d320badac (diff) | |
| download | emacs-833e7ac3fcc6652177daf10c01e9656587df87eb.tar.gz emacs-833e7ac3fcc6652177daf10c01e9656587df87eb.zip | |
* dired.el (dired-read-dir-and-switches): Use read-file-name.
| -rw-r--r-- | lisp/ChangeLog | 2 | ||||
| -rw-r--r-- | lisp/dired.el | 54 |
2 files changed, 25 insertions, 31 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index d290e1bbea0..a9aae768dbb 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,7 @@ | |||
| 1 | 2008-05-13 Stefan Monnier <monnier@iro.umontreal.ca> | 1 | 2008-05-13 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 2 | ||
| 3 | * dired.el (dired-read-dir-and-switches): Use read-file-name. | ||
| 4 | |||
| 3 | * dired.el (dired-read-dir-and-switches): Ignore ., .., and | 5 | * dired.el (dired-read-dir-and-switches): Ignore ., .., and |
| 4 | completion-ignored-extension directories if there's something else. | 6 | completion-ignored-extension directories if there's something else. |
| 5 | (dired-mark-if, dired-map-over-marks, dired-readin, dired-revert) | 7 | (dired-mark-if, dired-map-over-marks, dired-readin, dired-revert) |
diff --git a/lisp/dired.el b/lisp/dired.el index e5e3dd2358b..fd1456a3332 100644 --- a/lisp/dired.el +++ b/lisp/dired.el | |||
| @@ -600,7 +600,6 @@ Don't use that together with FILTER." | |||
| 600 | nil default-directory nil) | 600 | nil default-directory nil) |
| 601 | (lexical-let ((default (and buffer-file-name | 601 | (lexical-let ((default (and buffer-file-name |
| 602 | (abbreviate-file-name buffer-file-name))) | 602 | (abbreviate-file-name buffer-file-name))) |
| 603 | (defdir default-directory) | ||
| 604 | (cie ())) | 603 | (cie ())) |
| 605 | (dolist (ext completion-ignored-extensions) | 604 | (dolist (ext completion-ignored-extensions) |
| 606 | (if (eq ?/ (aref ext (1- (length ext)))) (push ext cie))) | 605 | (if (eq ?/ (aref ext (1- (length ext)))) (push ext cie))) |
| @@ -608,36 +607,29 @@ Don't use that together with FILTER." | |||
| 608 | (minibuffer-with-setup-hook | 607 | (minibuffer-with-setup-hook |
| 609 | (lambda () | 608 | (lambda () |
| 610 | (setq minibuffer-default default) | 609 | (setq minibuffer-default default) |
| 611 | (set (make-local-variable 'minibuffer-completing-file-name) | 610 | (setq minibuffer-completion-table |
| 612 | ;; t means "from now until the next minibuffer", whereas | 611 | ;; We need a mix of read-file-name and |
| 613 | ;; `lambda' means "only here". | 612 | ;; read-directory-name so that completion to directories |
| 614 | 'lambda) | 613 | ;; is preferred, but if the user wants to enter a global |
| 615 | (set (make-local-variable 'completion-ignore-case) | 614 | ;; pattern, he can still use completion on filenames to |
| 616 | read-file-name-completion-ignore-case) | 615 | ;; help him write the pattern. |
| 617 | (setq default-directory defdir)) | 616 | ;; Essentially, we want to use |
| 618 | (substitute-in-file-name | 617 | ;; (completion-table-with-predicate |
| 619 | (completing-read | 618 | ;; 'read-file-name-internal 'file-directory-p nil) |
| 620 | (format "Dired %s(directory): " str) | 619 | ;; but that doesn't work because read-file-name-internal |
| 621 | ;; We need a mix of read-file-name and read-directory-name | 620 | ;; does not obey its `predicate' argument. |
| 622 | ;; so that completion to directories is preferred, but if | 621 | (completion-table-in-turn |
| 623 | ;; the user wants to enter a global pattern, he can still | 622 | (lambda (str pred action) |
| 624 | ;; use completion on filenames to help him write the pattern. | 623 | (let ((read-file-name-predicate |
| 625 | ;; Essentially, we want to use | 624 | (lambda (f) (and (not (member f '("./" "../"))) |
| 626 | ;; (completion-table-with-predicate | 625 | ;; Hack! Faster than file-directory-p! |
| 627 | ;; 'read-file-name-internal 'file-directory-p nil) | 626 | (eq (aref f (1- (length f))) ?/) |
| 628 | ;; but that doesn't work because read-file-name-internal | 627 | (not (string-match cie f)))))) |
| 629 | ;; does not obey its `predicate' argument. | 628 | (complete-with-action |
| 630 | (completion-table-in-turn | 629 | action 'read-file-name-internal str nil))) |
| 631 | (lambda (str pred action) | 630 | 'read-file-name-internal))) |
| 632 | (let ((read-file-name-predicate | 631 | (read-file-name (format "Dired %s(directory): " str) |
| 633 | (lambda (f) (and (not (member f '("./" "../"))) | 632 | nil default-directory nil))))))) |
| 634 | ;; Hack! Faster than file-directory-p! | ||
| 635 | (eq (aref f (1- (length f))) ?/) | ||
| 636 | (not (string-match cie f)))))) | ||
| 637 | (complete-with-action | ||
| 638 | action 'read-file-name-internal str nil))) | ||
| 639 | 'read-file-name-internal) | ||
| 640 | nil nil (abbreviate-file-name defdir) 'file-name-history)))))))) | ||
| 641 | 633 | ||
| 642 | ;;;###autoload (define-key ctl-x-map "d" 'dired) | 634 | ;;;###autoload (define-key ctl-x-map "d" 'dired) |
| 643 | ;;;###autoload | 635 | ;;;###autoload |