From e2a9609eece317148c0d11bd5e68d541ff7060fb Mon Sep 17 00:00:00 2001 From: Allen Li Date: Sat, 25 Jun 2022 20:17:57 -0700 Subject: [PATCH 1/2] find-dired: Factor out find-dired--escaped-ls-option Deduplicate this logic for other future find-dired commands. * lisp/find-dired.el (find-dired--escaped-ls-option): New function. (find-dired): Use find-dired--escaped-ls-option. --- lisp/find-dired.el | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/lisp/find-dired.el b/lisp/find-dired.el index 61e626080e..bbdf452208 100644 --- a/lisp/find-dired.el +++ b/lisp/find-dired.el @@ -209,13 +209,7 @@ find-dired " " args " " (shell-quote-argument ")") " ")) - (if (string-match "\\`\\(.*\\) {} \\(\\\\;\\|\\+\\)\\'" - (car find-ls-option)) - (format "%s %s %s" - (match-string 1 (car find-ls-option)) - (shell-quote-argument "{}") - find-exec-terminator) - (car find-ls-option)))) + (find-dired--escaped-ls-option))) ;; Start the find process. (shell-command (concat args "&") (current-buffer)) (dired-mode dir (cdr find-ls-option)) @@ -256,6 +250,16 @@ find-dired (move-marker (process-mark proc) (point) (current-buffer))) (setq mode-line-process '(":%s")))) +(defun find-dired--escaped-ls-option () + "Return the car of `find-ls-option' escaped for a shell command." + (if (string-match "\\`\\(.*\\) {} \\(\\\\;\\|\\+\\)\\'" + (car find-ls-option)) + (format "%s %s %s" + (match-string 1 (car find-ls-option)) + (shell-quote-argument "{}") + find-exec-terminator) + (car find-ls-option))) + (defun kill-find () "Kill the `find' process running in the current buffer." (interactive) -- 2.36.1