diff options
| author | Stefan Monnier | 2008-05-13 16:18:17 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2008-05-13 16:18:17 +0000 |
| commit | b575007b0a100d1daf0ca727a7451d52cb617d56 (patch) | |
| tree | f1e21d12542e03f9e6e4968c55d2ec44950e4cab | |
| parent | 833e7ac3fcc6652177daf10c01e9656587df87eb (diff) | |
| download | emacs-b575007b0a100d1daf0ca727a7451d52cb617d56.tar.gz emacs-b575007b0a100d1daf0ca727a7451d52cb617d56.zip | |
(dired-read-dir-and-switches): Move things about to use less
recursion during macroexpansion.
| -rw-r--r-- | lisp/ChangeLog | 3 | ||||
| -rw-r--r-- | lisp/dired.el | 61 |
2 files changed, 35 insertions, 29 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index a9aae768dbb..5ebdbb9bb64 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,8 @@ | |||
| 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): Move things about to use less | ||
| 4 | recursion during macroexpansion. | ||
| 5 | |||
| 3 | * dired.el (dired-read-dir-and-switches): Use read-file-name. | 6 | * dired.el (dired-read-dir-and-switches): Use read-file-name. |
| 4 | 7 | ||
| 5 | * dired.el (dired-read-dir-and-switches): Ignore ., .., and | 8 | * dired.el (dired-read-dir-and-switches): Ignore ., .., and |
diff --git a/lisp/dired.el b/lisp/dired.el index fd1456a3332..d15e32f70fb 100644 --- a/lisp/dired.el +++ b/lisp/dired.el | |||
| @@ -598,38 +598,41 @@ Don't use that together with FILTER." | |||
| 598 | (if (next-read-file-uses-dialog-p) | 598 | (if (next-read-file-uses-dialog-p) |
| 599 | (read-directory-name (format "Dired %s(directory): " str) | 599 | (read-directory-name (format "Dired %s(directory): " str) |
| 600 | nil default-directory nil) | 600 | nil default-directory nil) |
| 601 | (lexical-let ((default (and buffer-file-name | 601 | (let ((cie ())) |
| 602 | (abbreviate-file-name buffer-file-name))) | ||
| 603 | (cie ())) | ||
| 604 | (dolist (ext completion-ignored-extensions) | 602 | (dolist (ext completion-ignored-extensions) |
| 605 | (if (eq ?/ (aref ext (1- (length ext)))) (push ext cie))) | 603 | (if (eq ?/ (aref ext (1- (length ext)))) (push ext cie))) |
| 606 | (setq cie (concat (regexp-opt cie "\\(?:") "\\'")) | 604 | (setq cie (concat (regexp-opt cie "\\(?:") "\\'")) |
| 607 | (minibuffer-with-setup-hook | 605 | (lexical-let* ((default (and buffer-file-name |
| 608 | (lambda () | 606 | (abbreviate-file-name buffer-file-name))) |
| 609 | (setq minibuffer-default default) | 607 | (cie cie) |
| 610 | (setq minibuffer-completion-table | 608 | (completion-table |
| 611 | ;; We need a mix of read-file-name and | 609 | ;; We need a mix of read-file-name and |
| 612 | ;; read-directory-name so that completion to directories | 610 | ;; read-directory-name so that completion to directories |
| 613 | ;; is preferred, but if the user wants to enter a global | 611 | ;; is preferred, but if the user wants to enter a global |
| 614 | ;; pattern, he can still use completion on filenames to | 612 | ;; pattern, he can still use completion on filenames to |
| 615 | ;; help him write the pattern. | 613 | ;; help him write the pattern. |
| 616 | ;; Essentially, we want to use | 614 | ;; Essentially, we want to use |
| 617 | ;; (completion-table-with-predicate | 615 | ;; (completion-table-with-predicate |
| 618 | ;; 'read-file-name-internal 'file-directory-p nil) | 616 | ;; 'read-file-name-internal 'file-directory-p nil) |
| 619 | ;; but that doesn't work because read-file-name-internal | 617 | ;; but that doesn't work because read-file-name-internal |
| 620 | ;; does not obey its `predicate' argument. | 618 | ;; does not obey its `predicate' argument. |
| 621 | (completion-table-in-turn | 619 | (completion-table-in-turn |
| 622 | (lambda (str pred action) | 620 | (lambda (str pred action) |
| 623 | (let ((read-file-name-predicate | 621 | (let ((read-file-name-predicate |
| 624 | (lambda (f) (and (not (member f '("./" "../"))) | 622 | (lambda (f) |
| 625 | ;; Hack! Faster than file-directory-p! | 623 | (and (not (member f '("./" "../"))) |
| 626 | (eq (aref f (1- (length f))) ?/) | 624 | ;; Hack! Faster than file-directory-p! |
| 627 | (not (string-match cie f)))))) | 625 | (eq (aref f (1- (length f))) ?/) |
| 628 | (complete-with-action | 626 | (not (string-match cie f)))))) |
| 629 | action 'read-file-name-internal str nil))) | 627 | (complete-with-action |
| 630 | 'read-file-name-internal))) | 628 | action 'read-file-name-internal str nil))) |
| 631 | (read-file-name (format "Dired %s(directory): " str) | 629 | 'read-file-name-internal))) |
| 632 | nil default-directory nil))))))) | 630 | (minibuffer-with-setup-hook |
| 631 | (lambda () | ||
| 632 | (setq minibuffer-default default) | ||
| 633 | (setq minibuffer-completion-table completion-table)) | ||
| 634 | (read-file-name (format "Dired %s(directory): " str) | ||
| 635 | nil default-directory nil)))))))) | ||
| 633 | 636 | ||
| 634 | ;;;###autoload (define-key ctl-x-map "d" 'dired) | 637 | ;;;###autoload (define-key ctl-x-map "d" 'dired) |
| 635 | ;;;###autoload | 638 | ;;;###autoload |