emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Thomas S. Dye" <tsd@tsdye.com>
To: Dan Davison <davison@stats.ox.ac.uk>
Cc: Org Mode Mailing List <emacs-orgmode@gnu.org>
Subject: Re: [babel]: Some feedback after the first week usage
Date: Fri, 6 Nov 2009 08:56:31 -1000	[thread overview]
Message-ID: <58597D98-A089-4566-896F-CC752DB4A65C@tsdye.com> (raw)
In-Reply-To: <87639o287h.fsf@stats.ox.ac.uk>


On Nov 5, 2009, at 7:27 AM, Dan Davison wrote:
> ...
> Yes, I think we do want a version of this for python and ruby et al.  
> In
> your example, the filename is created in python. I suggest doing it
> slightly differently, something like this.
>
> #+srcname: fileoutput
> #+begin_src python :file outfile.txt
>  def savetofile(result, filename):
>      with open(filename, 'w') as f:
>          f.write(str(result))
>  savetofile(78, 'outfile.txt')
>  55
> #+end_src
>
> #+resname: fileoutput
> [[file:outfile.txt]]
>
> This functionality is now available for ruby & python in branch
> ded-babel of git://repo.or.cz/org-mode/babel.git.
>
> So here, if you specify :file <filepath> ruby/python blindly outputs a
> link to <filepath>, regardless of the contents of the
> code. Responsibility for creating useful contents of <filepath> lies
> with the code. Notice that with this you have to specify the output  
> file
> twice: once as an org-babel directive, and once in the python code.  
> This
> is in contrast to the graphics languages (dot, ditaa, asymptote),  
> where
> the results *automatically* get sent to the file specified by :file.  
> The
> same is also true now for graphical output from R.
>
> The difference with python, ruby et al is that they might create file
> output in a variety of ways which we can't anticipate, so we can't
> automatically send output to the file. In contrast, the graphics
> language *always* create file output and always do it in the same
> way. [And in R it is possible to divert all graphical output to  
> file] A
> possible extension of the above might be to use a "magic variable" so
> that a python variable is created e.g. __org_babel_output_file__ that
> always holds a string corresponding to the file specified by :file.  
> Eric
> may have further ideas / views here.
> ...


Aloha Dan,

Nice idea.  It is great to have a link to the graphic in the org file.

With the graphics file name available to org-babel, it might be useful  
to have

<<fileoutput()>>

or some such thing, return the file name.  Then one could do something  
like this:

#+begin_src latex
...
\includegraphics{<<fileoutput()>>}
...
#+end_src

This way the file name would only have to be specified twice, and not  
every time other code wanted to refer to the output of fileoutput.

All the best,
Tom

  parent reply	other threads:[~2009-11-06 18:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-05  8:27 [babel]: Some feedback after the first week usage Torsten Wagner
2009-11-05 15:57 ` Thomas S. Dye
2009-11-06  1:34   ` Torsten Wagner
2009-11-05 17:27 ` Dan Davison
2009-11-05 22:48   ` Tom Short
2009-11-06 18:56   ` Thomas S. Dye [this message]
2009-11-06  0:02 ` Eric Schulte

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=58597D98-A089-4566-896F-CC752DB4A65C@tsdye.com \
    --to=tsd@tsdye.com \
    --cc=davison@stats.ox.ac.uk \
    --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).