From 3831be3067f97734137134e40e3e4467abd49816 Mon Sep 17 00:00:00 2001 From: Allen Li Date: Tue, 2 Mar 2021 14:24:16 -0800 Subject: [PATCH] find-dired: Add global-args to find-dired The original find-dired does not allow for constructing queries like find . -maxdepth 3 \( OTHER-ARGS \) -ls * lisp/find-dired.el (find-dired): Added optional parameter. --- etc/NEWS | 4 ++++ lisp/find-dired.el | 10 ++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 73f136cfa7..40f79f8232 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -653,6 +653,10 @@ keys, add the following to your init file: (global-set-key "\C-x\C-j" nil) (global-set-key "\C-x4\C-j" nil) +--- +*** Optional 'global-args' parameter added to 'find-dired'. +This allows passing find global options like -maxdepth. + ** Change Logs and VC *** More VC commands can be used from non-file buffers. diff --git a/lisp/find-dired.el b/lisp/find-dired.el index adc5672eca..fc35cccddd 100644 --- a/lisp/find-dired.el +++ b/lisp/find-dired.el @@ -157,14 +157,15 @@ find-args-history (defvar dired-sort-inhibit) ;;;###autoload -(defun find-dired (dir args) +(defun find-dired (dir args &optional global-args) "Run `find' and go into Dired mode on a buffer of the output. The command run (after changing into DIR) is essentially - find . \\( ARGS \\) -ls + find . GLOBAL-ARGS \\( ARGS \\) -ls except that the car of the variable `find-ls-option' specifies what to -use in place of \"-ls\" as the final argument. +use in place of \"-ls\" as the final argument. GLOBAL-ARGS is empty +when called interactively. Collect output in the \"*Find*\" buffer. To kill the job before it finishes, type \\[kill-find]." @@ -202,6 +203,7 @@ find-dired (setq default-directory dir find-args args ; save for next interactive call args (concat find-program " . " + (if global-args global-args "") (if (string= args "") "" (concat @@ -393,7 +395,7 @@ find-dired-sentinel ;; will stay around until M-x `list-processes'. (delete-process proc) (force-mode-line-update)))) - (message "find-dired %s finished." buf)))) + (message "find-dired %s finished." buf)))) (defun find-dired-sort-by-filename () "Sort entries in *Find* buffer by file name lexicographically." -- 2.30.1