From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: sbaugh@catern.com Newsgroups: gmane.emacs.devel Subject: Re: Teaching emacsclient to act as a pager, and more Date: Fri, 09 Sep 2016 17:13:33 -0400 Message-ID: <87sht83hfm.fsf@earth.catern.com> References: <1465262706-5229-1-git-send-email-sbaugh@catern.com> <87twfevqu7.fsf@earth.catern.com> <87pood5fee.fsf@earth.catern.com> <87inu55aln.fsf@earth.catern.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1473455691 6282 195.159.176.226 (9 Sep 2016 21:14:51 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 9 Sep 2016 21:14:51 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Sep 09 23:14:47 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1biT8J-0001EZ-Bx for ged-emacs-devel@m.gmane.org; Fri, 09 Sep 2016 23:14:47 +0200 Original-Received: from localhost ([::1]:60293 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1biT8K-0000Kc-1t for ged-emacs-devel@m.gmane.org; Fri, 09 Sep 2016 17:14:48 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:34931) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1biT7k-0008R9-0W for emacs-devel@gnu.org; Fri, 09 Sep 2016 17:14:13 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1biT7f-0005co-N3 for emacs-devel@gnu.org; Fri, 09 Sep 2016 17:14:10 -0400 Original-Received: from [195.159.176.226] (port=37121 helo=blaine.gmane.org) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1biT7f-0005cE-Fy for emacs-devel@gnu.org; Fri, 09 Sep 2016 17:14:07 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1biT7Q-0003vZ-2K for emacs-devel@gnu.org; Fri, 09 Sep 2016 23:13:52 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 44 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:vTUGkJ+gQVIBLB6onWEesLDYqcY= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 195.159.176.226 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:207343 Archived-At: Stefan Monnier 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 emacsclient. 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.