bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#64897: 29.0.91; Bug (and patch) in find-dired-with-command


From: Michael Albinus
Subject: bug#64897: 29.0.91; Bug (and patch) in find-dired-with-command
Date: Thu, 27 Jul 2023 17:55:51 +0200
User-agent: Gnus/5.13 (Gnus v5.13)

Warren Lynn <wrn.lynn@gmail.com> writes:

Hi Warren,

> On Linux. When I call "find-name-dired" command, which in turn invokes
> "find-dired-with-command" function, in a multi-hop tramp remote
> directory, an error will occur in side the function, with backtrace
> (only shown lowest level):
>
> Debugger entered--Lisp error: (wrong-type-argument processp nil)
>   process-mark(nil)
>   (move-marker (process-mark proc) (point) (current-buffer))

I confirm the bug (tested on Emacs 30.0.50). It happens even on a simple
remote connection; no multi-hop needed.

> The issue is around this part of the code:
>
>     ;; Start the find process.
>     (shell-command (concat command "&") (current-buffer))
>     (let ((proc (get-buffer-process (current-buffer)))) ;; !!!!!!!!
> proc could be nil here !!!!!!!!!!
>       ;; Initialize the process marker; it is used by the filter.
>       (move-marker (process-mark proc) (point) (current-buffer))
>
> After changing the code to:
>
>     ;; Start the find process.
>     (let ((proc (shell-command (concat command "&")
> (current-buffer))))
>       ;; Initialize the process marker; it is used by the filter.
>       (move-marker (process-mark proc) (point) (current-buffer))
>
> I do not have the error any more.

That patch isn't correct. It assumes, that an async shell-command returns
the process object. However, the documentation doesn't specify the
return value. And indeed, the type is different in the local and the
remote case:

--8<---------------cut here---------------start------------->8---
(let ((default-directory "/"))
 (shell-command "ls &"))
=> #<window 21 on *Async Shell Command*>

(let ((default-directory "/ssh::"))
 (shell-command "ls &"))
=> #<process *Async Shell Command*>
--8<---------------cut here---------------end--------------->8---

It is sheer luck for you, that in the remote case the process object is
returned.

> However, I observe that even with my fix above, the behavior is not
> completely right. Sometimes, the (found) file entries appear before
> the dired buffer header line. My impression of the code is it does not
> handle asynchronous timing in a robust way, and that is more of a
> problem when the command is invoked from a remote directory. Probably
> some serious revamp is needed here, which is beyond my expertise.
> Maybe Emacs should include the "aio" package and rely on that for
> asynchronous event handling.

There seem to be timing problems, indeed. And I believe using
make-process instead of shell-command would give us better control over
the process.

Best regards, Michael.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]