From mboxrd@z Thu Jan 1 00:00:00 1970 From: Charles Berry Subject: Re: input data for babel blocks Date: Tue, 1 Oct 2013 15:29:57 +0000 (UTC) Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:59735) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VR1u1-0004hO-Q0 for emacs-orgmode@gnu.org; Tue, 01 Oct 2013 11:30:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VR1tw-0002l4-Ul for emacs-orgmode@gnu.org; Tue, 01 Oct 2013 11:30:21 -0400 Received: from plane.gmane.org ([80.91.229.3]:42392) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VR1tw-0002ie-OA for emacs-orgmode@gnu.org; Tue, 01 Oct 2013 11:30:16 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1VR1tu-0007Ab-RP for emacs-orgmode@gnu.org; Tue, 01 Oct 2013 17:30:15 +0200 Received: from 137.110.34.64 ([137.110.34.64]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 01 Oct 2013 17:30:14 +0200 Received: from ccberry by 137.110.34.64 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 01 Oct 2013 17:30:14 +0200 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: emacs-orgmode@gnu.org Alan Schmitt polytechnique.org> 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). > Sorry if it was a bit obtuse. The examples given by others seem to have helped. And I will give one more. [deleted] > 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. > Here is what I use for LaTeX thru elisp to R: * Quote Blocks quote-blks takes two args: - blk :: a string of comma separated src block names - sep :: an optional separator for use when there is more than one block I usually save it in a file and load it in with (org-babel-lob-ingest file). But you can copy and paste and the example below will still work. #+name: quote-blks #+BEGIN_SRC emacs-lisp :var blk="abc" :var sep="\"\n\"" (save-excursion (replace-regexp-in-string "\"\"" "" (mapconcat (lambda (x) (org-babel-goto-named-src-block x) (format "%S" (cadr (org-babel-get-src-block-info t)))) (split-string blk "," t) sep) t t)) #+END_SRC * example of use The LaTeX here can be editted via C-c ' (i.e. org-edit-special --> org-edit-src-code). #+name: lstuff #+BEGIN_SRC latex :eval never :exports none Here is a \backslash. And an unmatched quote: '. #+END_SRC Here is an example using it on the above block. The cat statement prints a formatted version. The str statement shows what R sees (but the outer quotes are not part of the string). #+BEGIN_SRC R :noweb yes :results output some.latex <- <> cat(some.latex,"\n") str(some.latex) #+END_SRC #+RESULTS: : Here is a \backslash. And an unmatched quote: '. : chr "Here is a \\backslash. And an unmatched quote: '." HTH, Chuck