emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Eric Schulte <schulte.eric@gmail.com>
To: Alan Schmitt <alan.schmitt@polytechnique.org>
Cc: emacs-orgmode@gnu.org, Charles Berry <ccberry@ucsd.edu>
Subject: Re: input data for babel blocks
Date: Tue, 01 Oct 2013 05:58:02 -0600	[thread overview]
Message-ID: <87r4c5p456.fsf@gmail.com> (raw)
In-Reply-To: m2y56do1f2.fsf@polytechnique.org

[-- Attachment #1: Type: text/plain, Size: 1700 bytes --]

Alan Schmitt <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
>>   <<elisp-conversion-to-mylang("arg1","arg2")>>
>> #+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.
>


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: noweb-variable-example.org --]
[-- Type: text/x-org, Size: 378 bytes --]

#+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
  <<table-as-array(data)>>
  (aref (aref it 1) 1)
#+end_src

#+RESULTS:
: 4


[-- Attachment #3: Type: text/plain, Size: 105 bytes --]


Hope this Helps,

>
> Thanks,
>
> Alan
>

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D

  reply	other threads:[~2013-10-01 12:28 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-30 12:50 input data for babel blocks Alan Schmitt
2013-09-30 16:26 ` Charles Berry
2013-10-01  0:08   ` Eric Schulte
2013-10-01  8:12   ` Alan Schmitt
2013-10-01 11:58     ` Eric Schulte [this message]
2013-10-01 13:01       ` Alan Schmitt
2013-10-01 14:29         ` Rick Frankel
2013-10-01 15:16           ` Alan Schmitt
2013-10-01 15:29     ` Charles Berry
2013-10-01 17:16       ` Alan Schmitt
2013-10-01 19:06       ` Thomas S. Dye
2013-10-01  0:04 ` Eric Schulte
2013-10-01  8:15   ` Alan Schmitt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87r4c5p456.fsf@gmail.com \
    --to=schulte.eric@gmail.com \
    --cc=alan.schmitt@polytechnique.org \
    --cc=ccberry@ucsd.edu \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).