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 16:38:16 -0400 Message-ID: <87r38s4xmv.fsf@earth.catern.com> References: <1465262706-5229-1-git-send-email-sbaugh@catern.com> <87twfevqu7.fsf@earth.catern.com> <87pood5fee.fsf@earth.catern.com> <834m5p83yy.fsf@gnu.org> <877fal56zh.fsf@earth.catern.com> <83d1kcaowk.fsf@gnu.org> <8737l86glg.fsf@earth.catern.com> <837fakan8b.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1473454611 24353 195.159.176.226 (9 Sep 2016 20:56:51 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 9 Sep 2016 20:56: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 22:56: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 1biSqj-0004pF-J0 for ged-emacs-devel@m.gmane.org; Fri, 09 Sep 2016 22:56:37 +0200 Original-Received: from localhost ([::1]:60199 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1biSqh-0007tt-Hg for ged-emacs-devel@m.gmane.org; Fri, 09 Sep 2016 16:56:35 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56489) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1biSZM-0001Pz-0d for emacs-devel@gnu.org; Fri, 09 Sep 2016 16:38:41 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1biSZG-0006Tn-Lh for emacs-devel@gnu.org; Fri, 09 Sep 2016 16:38:39 -0400 Original-Received: from [195.159.176.226] (port=41717 helo=blaine.gmane.org) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1biSZG-0006So-Eo for emacs-devel@gnu.org; Fri, 09 Sep 2016 16:38:34 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1biSZ8-0007zf-Qm for emacs-devel@gnu.org; Fri, 09 Sep 2016 22:38:26 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 54 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:yeYNmTr3PyttAR4iosEcV5Wpk7M= 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:207340 Archived-At: Eli Zaretskii writes: >> From: sbaugh@catern.com >> 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 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.