From: "Eric Schulte" <schulte.eric@gmail.com>
To: Sebastian Rose <sebastian_rose@gmx.de>
Cc: Org Mode <emacs-orgmode@gnu.org>
Subject: Re: [Announcement] Org-babel initial release
Date: Tue, 15 Sep 2009 11:54:36 -0600 [thread overview]
Message-ID: <m2my4w9jpv.fsf@gmail.com> (raw)
In-Reply-To: 87pr9sazlr.fsf@gmx.de
Hi Sebastian,
Sebastian Rose <sebastian_rose@gmx.de> writes:
> "Eric Schulte" <schulte.eric@gmail.com> writes:
>> Dan Davison and I (Eric Schulte) are happy to announce that Org-babel
>> has now been released as a contributed package in Org-mode with
>> corresponding documentation on worg [1].
>
>
> What else should I say - THIS IS GREAT NEWS!!
>
Thanks, I hope fellow Orgers find it useful
>
> I wonder how complicated it would be to add more languages. Especially
> PHP, JavaScript (e.g. per rhino) and Perl.
>
Yes, I must admit the current set of implemented language is very
specific to Dan and my personal needs. I really hope that other people
add the languages they need/use, and I tried to design the structure of
org-babel to make the addition of new languages as painless as possible.
>
> Is there some documentation or advice on the net in that concern? I'd
> like to add a language I understand besides Bash... :)
>
> Hmmm - maybe `org-babel-sh.el' is a good starting point.
>
Yes, currently the best way to get a feel for how to add languages would
be to start with an existing language file (I'd suggest
org-babel-python.el or org-babel-ruby.el, or for simpler less
comprehensive language support look at org-babel-ditaa or
org-babel-haskell) and make changes from there. I agree that a brief
tutorial for adding language support would be helpful.
Basically Org-babel expects any new language file to define two
functions...
- org-babel-execute:lang-name (body params) :: which executes the code
in body according to the header arguments in params, and
- org-babel-prep-session:ruby (session params) :: which starts an
interactive session in session setting any variables from params
>
> * Some thoughts
>
>
> I actually wonder, if all those interpreted languages are different at
> all. Why not add an generic call to interpreters. Executing Shell
> scripts or Perl, Php, JavaScript... makes no big difference here. On
> Linux at least, they all work with either shebang or called with OPTION
> FILENAME.
>
There are two key language specific features which keep us from treating
all interpreted languages identically.
1) Org-babel collects the last value of a source-code block to be
returned (see [1]) and this value needs to be collected and
potentially converted into elisp in a language specific manner
2) Org-babel has support for evaluation in a session allowing
persistence of state between different blocks which use the same
session. I now notice that the :session header argument is not
currently documented on the Worg page. I'll try to add this
documentation soon. The sessions are handled through Emacs comint
buffers which are very language specific.
>
> To execute a temporary file without shebang, all interpreters take a
> filename:
>
> rhino -f FILE # -f is optional
> php -f FILE # -f is optional
> perl FILE
>
> Or execute code directly (which is useless for us, since we would need
> to quote the code correctly...):
>
> rhino -e CODE...
> perl -e CODE...
> php -r CODE...
>
I agree that it would be possible to implement a much more general
code-evaluation mechanism based on execution of temporary files, but we
would lose the nice features mentioned above.
>
>
> So how about:
>
> #+srcname: generic-circumference(a)
> #+begin_src javascript :interpreter rhino -f
>
> print ( "Write me to temp file and call `rhino -f TMPFILE'" )
> java.lang.System.out.println ( 2 * a * java.lang.Math.PI )
>
> #+end_src
>
> This way, a source block written on my Linux-System would execute on her
> MAC and his Windows machine without change (provided the interpreter is
> installed and in $PATH... `org-program-exists' ... to use interpreters
> without having them in $PATH, a customizable map could be used).
>
Under the current setup, all source-code blocks should be executable on
*any* system which supports the required language and Emacs modes
mentioned in the commented elisp block at [2]
Best -- Eric
>
>
>
>
>
>
> BTW: I just discovered rhino - looks interesting, seems you can
> (de-)serialize Java(Script) objects... and thus keep track of things
> between sessions ;) start programs, call Java Methods... See
> https://developer.mozilla.org/en/Rhino_Shell
>
>
>
> Best wishes,
>
> Sebastian
Footnotes:
[1] http://orgmode.org/worg/org-contrib/babel/org-babel.php#results
[2] http://orgmode.org/worg/org-contrib/babel/org-babel.php#languages
next prev parent reply other threads:[~2009-09-15 17:55 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-14 13:44 [Announcement] Org-babel initial release Eric Schulte
2009-09-15 8:20 ` Carsten Dominik
2009-09-15 13:31 ` Miguel Fernando Cabrera
2009-09-15 14:49 ` Eric Schulte
2009-09-15 15:10 ` Eric Schulte
2009-09-15 17:26 ` Sebastian Rose
2009-09-15 17:54 ` Eric Schulte [this message]
2009-09-15 19:15 ` Sebastian Rose
2009-09-15 20:03 ` Eric Schulte
2009-09-15 20:53 ` Sebastian Rose
2009-09-15 17:56 ` Rick Moynihan
2009-09-15 20:07 ` Eric Schulte
2009-09-15 22:02 ` Eric Schulte
2009-10-09 16:38 ` Marcelo de Moraes Serpa
2009-10-09 12:54 ` Org-babel for jython? Eric S Fraga
2009-10-09 15:34 ` Dan Davison
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m2my4w9jpv.fsf@gmail.com \
--to=schulte.eric@gmail.com \
--cc=emacs-orgmode@gnu.org \
--cc=sebastian_rose@gmx.de \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.