From: Stefan Monnier Date: Tue, 13 May 2008 16:18:17 +0000 (+0000) Subject: (dired-read-dir-and-switches): Move things about to use less X-Git-Tag: emacs-pretest-23.0.90~5602 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=b575007b0a100d1daf0ca727a7451d52cb617d56;p=emacs.git (dired-read-dir-and-switches): Move things about to use less recursion during macroexpansion. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index a9aae768dbb..5ebdbb9bb64 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,8 @@ 2008-05-13 Stefan Monnier + * dired.el (dired-read-dir-and-switches): Move things about to use less + recursion during macroexpansion. + * dired.el (dired-read-dir-and-switches): Use read-file-name. * 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." (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))) - (cie ())) + (let ((cie ())) (dolist (ext completion-ignored-extensions) (if (eq ?/ (aref ext (1- (length ext)))) (push ext cie))) (setq cie (concat (regexp-opt cie "\\(?:") "\\'")) - (minibuffer-with-setup-hook - (lambda () - (setq minibuffer-default default) - (setq minibuffer-completion-table - ;; 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 - (lambda (f) (and (not (member f '("./" "../"))) - ;; Hack! Faster than file-directory-p! - (eq (aref f (1- (length f))) ?/) - (not (string-match cie f)))))) - (complete-with-action - action 'read-file-name-internal str nil))) - 'read-file-name-internal))) - (read-file-name (format "Dired %s(directory): " str) - nil default-directory nil))))))) + (lexical-let* ((default (and buffer-file-name + (abbreviate-file-name buffer-file-name))) + (cie cie) + (completion-table + ;; 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 + (lambda (f) + (and (not (member f '("./" "../"))) + ;; Hack! Faster than file-directory-p! + (eq (aref f (1- (length f))) ?/) + (not (string-match cie f)))))) + (complete-with-action + action 'read-file-name-internal str nil))) + 'read-file-name-internal))) + (minibuffer-with-setup-hook + (lambda () + (setq minibuffer-default default) + (setq minibuffer-completion-table completion-table)) + (read-file-name (format "Dired %s(directory): " str) + nil default-directory nil)))))))) ;;;###autoload (define-key ctl-x-map "d" 'dired) ;;;###autoload