From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Schulte Subject: Re: input data for babel blocks Date: Tue, 01 Oct 2013 05:58:02 -0600 Message-ID: <87r4c5p456.fsf@gmail.com> References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:39589) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VQz3f-00007p-Kt for emacs-orgmode@gnu.org; Tue, 01 Oct 2013 08:28:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VQz3b-0008DT-6g for emacs-orgmode@gnu.org; Tue, 01 Oct 2013 08:28:07 -0400 Received: from mail-pb0-x22e.google.com ([2607:f8b0:400e:c01::22e]:43479) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VQz3a-0008DG-Ub for emacs-orgmode@gnu.org; Tue, 01 Oct 2013 08:28:03 -0400 Received: by mail-pb0-f46.google.com with SMTP id rq2so7007434pbb.5 for ; Tue, 01 Oct 2013 05:28:01 -0700 (PDT) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Alan Schmitt Cc: emacs-orgmode@gnu.org, Charles Berry --=-=-= Content-Type: text/plain Alan Schmitt writes: > Hi Charles, > > ccberry@ucsd.edu writes: > >> Lacking that, another alternative to the approach you have crafted is to >> use elisp src blocks to set up the commands needed to create the objects, >> and then place the results of executing the elisp src block in the src >> block of your favored language using noweb, for example >> >> #+BEGIN_SRC mylang :noweb yes >> <> >> #+END_SRC >> >> might convert 'arg2' to an object of the desired type named 'arg1' in a >> 'mylang' src block. > > This looks like a very powerful approach, but it's a bit beyond my > understanding of babel (which is limited) and noweb (whose existence I > just discovered after reading http://orgmode.org/manual/noweb.html). > > The way I understand it is: > - there is somewhere in the file a "elisp-conversion-to-mylang" > function; > - upon export or evaluation or tangling, it will be expanded in the body > of the source block; > - it will then be evaluated in the source block. > > What I don't understand is: > - how to define this function; It is not a function name, it is a code block name. See the noweb section of the Org-mode manual for more information. > > - will it be evaluated as a "mylang" function or as a function in the > language it is defined? > > In other words, do we have "evaluate elisp-conversion-to-mylang in its > language then substitute the results in the noweb block" or "substitute > the function in the noweb block then evaluate it"? > see above > > If you have an example that uses different languages, I'd love to look > at it. I'll then try to write an example for ocaml. > --=-=-= Content-Type: text/x-org Content-Disposition: inline; filename=noweb-variable-example.org #+name: data | x | 2 | | y | 4 | #+name: table-as-array #+begin_src sh :var data=data :results verbatim echo "$data"|sed 's/\s/ /;s/^/ [/;s/$/]/;1 s/^\s\+/(setf it [/; $ s/$/])/' #+end_src #+RESULTS: table-as-array : (setf it [[x 2] : [y 4]]) #+begin_src emacs-lisp :noweb yes <> (aref (aref it 1) 1) #+end_src #+RESULTS: : 4 --=-=-= Content-Type: text/plain Hope this Helps, > > Thanks, > > Alan > -- Eric Schulte https://cs.unm.edu/~eschulte PGP: 0x614CA05D --=-=-=--