]> git.eshelyaron.com Git - emacs.git/commitdiff
find-dired: Factor out find-dired--escaped-ls-option
authorAllen Li <darkfeline@felesatra.moe>
Mon, 27 Jun 2022 07:44:29 +0000 (09:44 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Mon, 27 Jun 2022 07:44:29 +0000 (09:44 +0200)
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

index 61e626080ea6d412e97af9ce8dfb7d29d056fad4..998ddbc721f389d288aa39b854e97ae2c5b51dad 100644 (file)
@@ -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)