[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to interact with a shell-like process behind the scenes?
From: |
mbork |
Subject: |
Re: How to interact with a shell-like process behind the scenes? |
Date: |
Thu, 22 May 2025 13:20:00 +0200 |
On 2025-05-21, at 15:37, Eli Zaretskii <eliz@gnu.org> wrote:
>> From: Yuri Khan <yuri.v.khan@gmail.com>
>> Date: Wed, 21 May 2025 13:19:04 +0700
>> Cc: Help Gnu Emacs mailing list <help-gnu-emacs@gnu.org>
>>
>> On Wed, 21 May 2025 at 10:42, <mbork@mbork.pl> wrote:
>>
>> > I have a program which displays a prompt on stdout, accepts a line of
>> > input, does something with it, displays the results (possibly in many
>> > lines, in a known format, e.g. JSON), and shows the prompt again.
>> > I need Emacs to be able to interact with it, as in: send the said line
>> > of input and receive the said output. I don't want the /user/ to do
>> > that, that is, I don't need it to be interactive in any way -- just that
>> > some Elisp function can "wrap" the process, as in, accept the input,
>> > send it to the process, and receive the output, most probably via
>> > a callback. How do I do that?
>>
>> What you’re describing is pretty much what happens between Emacs and
>> gdb, or Emacs and a language server, so you might find some
>> inspiration in gdb-mi or jsonrpc. (A notable difference is that
>> language servers do not have prompts.)
>
> Another relevant example is ispell.el, which runs the spell-checking
> program via stdin/stdout, and without the user typing any commands
> him/herself.
Thanks, I'll look into that, too.
> When the sub-process dies for some reason, Emacs calls the sentinel
> function, which can do whatever is appropriate in this case.
>
> So this is pretty much a very frequent paradigm in Emacs.
That was what I was (kind of) expecting. It seems there is no
abstraction over this, though (at least not built in), right?
Thanks,
--
Marcin Borkowski
https://mbork.pl
https://crimsonelevendelightpetrichor.net/
Re: How to interact with a shell-like process behind the scenes?, mbork, 2025/05/22
Re: How to interact with a shell-like process behind the scenes?, Ship Mints, 2025/05/21
Re: How to interact with a shell-like process behind the scenes?, Eduardo Ochs, 2025/05/22