emacs-devel
[Top][All Lists]
Advanced

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

Re: emacsclient in elisp


From: Daniel Mendler
Subject: Re: emacsclient in elisp
Date: Thu, 20 May 2021 22:54:45 +0200

On 5/20/21 9:45 PM, Eli Zaretskii wrote:
> But then I don't understand the importance of stdin in this context.
> If you want to read output from another program, just run that
> program, in this case another Emacs, as a subprocess.  Then anything
> that other program writes to its stdout will be read as part of normal
> machinery of reading sub-process output, including filters, sentinels,
> and all that.

Yes, that's right. I have two Emacs processes A and B. The process A
starts process B as subprocess and communicates with it via the pipe.
The process B reads from the stdin using `(read t)` or
`(read-from-minibuffer..)`. Now process B starts another subprocess C,
which has a filter and a sentinel. While B reads from stdin, B hangs and
the C-filter is not executed.

Alternatively one can use network streams. A creates a server, B creates
a client and then they communicate asynchronously, B can start a
subprocess C and the AB-network communication does not impede the
subprocess C.

> It really does matter, because without understanding these details we
> cannot make sure we are on the same page discussing these matters.  I
> understand that you have something specific in mind, but if you don't
> describe that something in enough detail for me to understand what you
> have in mind, we will be forever mis-communicating.

I would like to offload work from Emacs to sub-Emacs processes which are
connected via some IPC protocol. I am currently using the emacsclient
protocol for this (with some custom extensions). Stefan suggested that
it may be better if the Emacs processes communicate directly using
pipes. But given the stdin blocking problem, described above, this is
not possible.

Actually I am happy with using the emacsclient protocol now. It is a bit
of a hack, but it works for the simple use case I am currently exploring
(https://github.com/minad/affe). There I have Emacs A (frontend)
starting an Emacs B (backend) which starts grep as a subprocess C,
generating output. Then A sends filter regular expressions to B, B
filters the output of C and answers with the matches.

Daniel



reply via email to

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