From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Eric Schulte" Subject: Re: [Babel] Piping between code blocks Was: Handling of errors when using Ledger Date: Sat, 27 Nov 2010 15:04:46 -0700 Message-ID: <87d3pqh18h.fsf_-_@gmail.com> References: <877hhudxor.fsf@mundaneum.com> <87sk0inmys.fsf@stats.ox.ac.uk> <807hhnfaix.fsf@mundaneum.com> <87mxqiv7q3.wl%ucecesf@ucl.ac.uk> <871v68eb5k.fsf@pinto.chemeng.ucl.ac.uk> <87vd3kxq69.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from [140.186.70.92] (port=44378 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PMSt4-0000ON-1m for emacs-orgmode@gnu.org; Sat, 27 Nov 2010 17:04:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PMSt2-0007Fy-NS for emacs-orgmode@gnu.org; Sat, 27 Nov 2010 17:04:53 -0500 Received: from mail-gy0-f169.google.com ([209.85.160.169]:64134) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PMSt2-0007Fq-Kw for emacs-orgmode@gnu.org; Sat, 27 Nov 2010 17:04:52 -0500 Received: by gyg10 with SMTP id 10so15387997gyg.0 for ; Sat, 27 Nov 2010 14:04:51 -0800 (PST) In-Reply-To: <87vd3kxq69.fsf@gmail.com> (Dan Davison's message of "Fri, 26 Nov 2010 11:47:10 +0000") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Dan Davison Cc: Eric S Fraga , emacs-orgmode@gnu.org Dan Davison writes: > > Incidentally, I have for a long time wondered whether we should permit > src blocks to read *input data* from standard input. This would require > altering ob-eval such that the src block body is read from file. Then we > could do things like > > #+source: output-some-text > #+begin_src sh :results output > # print stuff > #+end_src > > #+begin_src perl :stdin output-some-text > while ( <> ) { > # process the text > } > #+end_src > This is interesting, it would involve starting all such pipe-chained blocks at the same time, and coordinating their input and output through Unix pipes (note: I don't know how pipes would work on a Windows machine). One question is whether we allow data to pass /directly/ between blocks, or if we insert babel in between to do its usual parsing (i.e. arrays into elisp lists, etc...). I'd lean against inserting babel as I believe this would be of use mainly for performance, and Emacs/Babel parsing would blow any performance gains. Also it could be difficult to implement. I think that in addition to the :stdin option above we would need a =:stdout= option would imply both =:results output= and =:results scalar= and would allow the process to write intermediate results directly to a supplied pipe. Perhaps such a :stdout option would never be supplied directly by the user, but would rather be used by babel to organize piping when that code block has referenced by another code block using :stdin. Does the above make sense or sound appealing? Best -- Eric