From: Allen Li Date: Mon, 27 Jun 2022 07:44:29 +0000 (+0200) Subject: find-dired: Factor out find-dired--escaped-ls-option X-Git-Tag: emacs-29.0.90~1447^2~1428 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=995fb1677d640784f1ca58ef99a71314a3ac9d30;p=emacs.git 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. --- diff --git a/lisp/find-dired.el b/lisp/find-dired.el index 61e626080ea..998ddbc721f 100644 --- a/lisp/find-dired.el +++ b/lisp/find-dired.el @@ -209,13 +209,7 @@ it finishes, type \\[kill-find]." " " 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 @@ it finishes, type \\[kill-find]." (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)