[Top][All Lists]

[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 17:13:33 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

Stefan Monnier <address@hidden> writes:
>> Couldn't we still do that anyway, even if current Emacs does not
>> misbehave when getting FDs? As long as it's opt-in.
> - emacsclient connects to emacs daemon in pretty much the normal way.
> - then (after warning the emacs daemon appropriately), turn the
>   emacsclient into a simple proxy which reads from its stdin and passes
>   that straight to the daemon's socket (and vice versa for the daemon
>   socket's output).
> This last strategy has the potential to be usable/useful even through
> TCP connections.

That is indeed an elegant API for solving this specific problem, and I
could implement it as a fallback for when fd-passing is not available.

It does have the issue that it adds another hop for the data to go
through, and needs more complicated polling/non-blocking logic in

But besides those issues, I still think an fd-based approach is useful.

First, I think (as I said in another mail) that Emacs should learn to
talk about file descriptors as a native Elisp type, since that would
open up a lot of capabilities which would be useful for (among other
things) improving Eshell.

So, assuming that Emacs knows how to talk about file descriptors, and
Emacs can act as a real Unix shell, it would be useful and interesting
to be able to pass in arbitrary file descriptors into a single Emacs
process. My patches use this capability to make a pager, of course. You
could also, say, pass in a file descriptor pointing to a file opened
with escalated privileges, and then manipulate it without needing to go
through sudo/su/TRAMP. Or the ability to pass around file descriptors in
this way could unlock novel shell features, since this is definitely not
something traditional Unix shells can do.

Anyway, the easiest way to pass an arbitrary file descriptor into Emacs
is by putting that file descriptor in emacsclient's stdin or stdout and
using these patches. And as I mentioned, this makes it trivially easy to
use emacsclient as a pager or filter.

So, even if the pager use case ends up always done through
emacsclient-as-a-proxy, I would still like some guidance on how (as a
first step) an FD type could be added to Emacs.

reply via email to

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