From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?utf-8?Q?S=C3=A9bastien_Vauban?= Subject: Re: [babel] How to kill two birds with one stone? Date: Mon, 28 Feb 2011 16:16:49 +0100 Message-ID: <80wrkknq8u.fsf@somewhere.org> References: <808vxv23j2.fsf@missioncriticalit.com> <80mxm9yulk.fsf@missioncriticalit.com> <87sjvj6oul.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: 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-mXXj517/zsQ@public.gmane.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org-mXXj517/zsQ@public.gmane.org To: emacs-orgmode-mXXj517/zsQ@public.gmane.org Hi Eric, "Eric Schulte" wrote: > I haven't followed this discussion very closely, but I'm not sure why it > would be necessary to pass data through STDIN rather than through a varia= ble > or an external file. > > I took a shot at the dot graph example you proposed, the following works = for > me over a simple example directory. For sure, your version works, but it does not address the two goals -- I ho= pe they don't exclude each other -- I wanna try to reach. This should clarify the subject. #+TITLE: graph-dir-eric-schulte #+DATE: 2011-02-28 #+LANGUAGE: en_US * Directory to search #+results: graph-dir : graph-dir * List all files in dir #+source: graph-files #+begin_src sh :results vector :var dir=3Dgraph-dir find $dir -type f -exec basename {} \; #+end_src #+results: graph-files | dan | | eric | | other | | seb_vauban | * Association of files with mentions #+source: graph-associations #+begin_src sh :var dir=3Dgraph-dir :var files=3Dgraph-files for i in $files; do for j in `grep -l -r $i $dir`; do echo $i, `basename $j` done done #+end_src #+results: graph-associations | dan | eric | | eric | seb_vauban | | other | eric | | other | seb_vauban | | seb_vauban | dan | * Ultimate goal The first goal of this document was to write small snippets of code, with a clear and concise specification, and test its results when applied on some input data. This goal is clearly met. Though, the following goal, the ultimate one, is to be able to output an independent shell script -- out of this stuff --, so that the program can be run independently by anybody, just from a simple shell. How could I write such a "combined" shell script? Something in the spirit of: #+source: graph-associations-sh-script #+begin_src sh :var dir=3Dgraph-dir :noweb yes cd $dir for i in `<>`; do for j in `grep -l -r $i $dir`; do echo $i, `basename $j` done done #+end_src #+results: graph-associations-sh-script But, of course (because of the =3Ddir=3D var?), the above does not work, at= least for my first goal: seeing "in situ" (part of) the results it returns when it is run. Maybe it's possible to reach both goals, maybe it's not -- I've no definite clue about this. - Maybe we need =3Dstdin=3D to be properly "handled" for this, nothing more? - Maybe we need to add some extra hard constraints on how to write the litt= le program parts, such as "don't use the Babel :var mechanism"? - Etc... * Executive summary To sum up what I'm trying to explain, I'd like the ability to write *and ru= n* small snippets of code, such as: #+source: block-1 #+begin_src sh ... do this... #+end_src #+source: block-2 #+begin_src sh ... do that... #+end_src *and* to be able to produce the shell script that would run them all from a shell (no need for Emacs), something like: #+source: full-code #+begin_src sh :tangle yes <> <> #+end_src or #+source: full-code #+begin_src sh :tangle yes <> | <> #+end_src or #+source: full-code #+begin_src sh :tangle yes for i in `<>`; do <> done #+end_src or ... (depending on what the code does) ... Which conditions would allow one to make both dreams true at the same time? Best regards, Seb --=20 S=C3=A9bastien Vauban _______________________________________________ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode-mXXj517/zsQ@public.gmane.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode