emacs-devel
[Top][All Lists]
Advanced

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

Re: Teaching emacsclient to act as a pager, and more


From: sbaugh
Subject: Re: Teaching emacsclient to act as a pager, and more
Date: Fri, 09 Sep 2016 16:38:16 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

Eli Zaretskii <address@hidden> writes:
>> From: address@hidden
>> Date: Fri, 09 Sep 2016 15:03:23 -0400
>>
>> > Looking at your patches, it seemed to me that you indeed need a pipe,
>> > no?
>>
>> Not as far as I know - what in my patches suggests that I need a pipe?
>
> A pipe is a set of 2 file descriptors between 2 programs, one of the
> descriptors is used for reading by one program and writing by the
> other, the other descriptor used similarly in the opposite direction.
> Isn't that what you set up?
>
> If not, then I must be missing something, so please describe the data
> flow between emacsclient, emacs server, and the external program.

There is not necessarily any external program. Even emacsclient can exit
just fine once the file descriptors are passed in and a process object
created from them.

Once a process object P is created, the data flow is as follows:

When emacs writes to P, emacs is directly writing to the file descriptor
that emacsclient had as its stdout. It is literally calling "write" on
the file descriptor that was/is emacsclient's stdout.

When emacs reads from P, emacs is directly reading from the file
descriptor that emacsclient had as its stdin. It is literally calling
"read" on the file descriptor that was/is emacsclient's stdin.

If I invoke emacsclient in my shell with "emacsclient <foo >bar", reads
from P will read from the file "bar", and writes to P will read from the
file "foo", with the data in both cases passing directly to emacs and
not first going through any other process.

>
>> I am just passing in the arbitrary file-descriptors that emacsclient has
>> as its stdin/stdout. They are directly moved into the main emacs
>> process, not tunneled over a pipe. Those file descriptors frequently
>> would be pipes, but could be regular files or anything else. And given
>> that I have these two arbitrary file descriptors, I need to manipulate
>> them somehow - and I do that by passing them into make-fd-process to
>> make a process object backed by those two arbitrary file descriptors.
>
> I'm trying to see if a higher-level abstraction can be used here,
> because passing file descriptors is too low-level and therefore less
> portable.

That is true, however I do want to eventually get an API for handling
file descriptors in Emacs, even if it is not portable. I believe it
would be useful for quite a lot. For example I would like to bring
eshell up to par with other Unix shells, and the ability to manipulate
file descriptors directly is pretty much required for that.




reply via email to

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