From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Thomas S. Dye" Subject: Re: [babel]: Some feedback after the first week usage Date: Fri, 6 Nov 2009 08:56:31 -1000 Message-ID: <58597D98-A089-4566-896F-CC752DB4A65C@tsdye.com> References: <200911051727.44814.torsten.wagner@googlemail.com> <87639o287h.fsf@stats.ox.ac.uk> Mime-Version: 1.0 (Apple Message framework v936) Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N6TzF-0002K2-DX for emacs-orgmode@gnu.org; Fri, 06 Nov 2009 13:56:41 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N6TzA-0002Gn-Dn for emacs-orgmode@gnu.org; Fri, 06 Nov 2009 13:56:40 -0500 Received: from [199.232.76.173] (port=52372 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N6TzA-0002Ge-8Y for emacs-orgmode@gnu.org; Fri, 06 Nov 2009 13:56:36 -0500 Received: from outbound-mail-24.bluehost.com ([69.89.21.19]:53779) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1N6Tz9-0006pb-Pb for emacs-orgmode@gnu.org; Fri, 06 Nov 2009 13:56:36 -0500 In-Reply-To: <87639o287h.fsf@stats.ox.ac.uk> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Dan Davison Cc: Org Mode Mailing List 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 ruby/python blindly outputs a > link to , regardless of the contents of the > code. Responsibility for creating useful contents of 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 <> or some such thing, return the file name. Then one could do something like this: #+begin_src latex ... \includegraphics{<>} ... #+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