Subject: bug#56865: M-x find-dired fails with "Wrong type: processp, nil"

From: Liu Hui <[email-masked]>
Date: Thu, 01 Dec 2022 15:33:08 +0800

Hi,

I create a patch according to the discussion and find-dired works well
now.

Best,
Hui

>From 8fbd85c80909b4cb560ec77cf84374e0a16b41df Mon Sep 17 00:00:00 2001
From: Liu Hui <[email-masked]>
Date: Thu, 1 Dec 2022 15:03:06 +0800
Subject: [PATCH] Set the filter/sentinel of find process reliably in
 find-dired

* lisp/find-dired.el (find-dired-with-command): Use `make-process'
rather than `shell-command' to start a find process.
---
 lisp/find-dired.el | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/lisp/find-dired.el b/lisp/find-dired.el
index be3d106912..3d1ece2003 100644
--- a/lisp/find-dired.el
+++ b/lisp/find-dired.el
@@ -240,12 +240,13 @@ find-dired-with-command
     (erase-buffer)
     (setq default-directory dir)
     ;; Start the find process.
-    (shell-command (concat command "&") (current-buffer))
-    (let ((proc (get-buffer-process (current-buffer))))
-      ;; Initialize the process marker; it is used by the filter.
-      (move-marker (process-mark proc) (point) (current-buffer))
-      (set-process-filter proc #'find-dired-filter)
-      (set-process-sentinel proc #'find-dired-sentinel))
+    (make-process
+     :name "find-dired"
+     :buffer (current-buffer)
+     :command (split-string-shell-command command)
+     :filter #'find-dired-filter
+     :sentinel #'find-dired-sentinel
+     :file-handler t)
     (dired-mode dir (cdr find-ls-option))
     (let ((map (make-sparse-keymap)))
       (set-keymap-parent map (current-local-map))
-- 
2.25.1