From mboxrd@z Thu Jan 1 00:00:00 1970 From: Juan Pechiar Subject: Re: [babel] using #+call for inline results Date: Wed, 22 Jun 2011 14:53:06 -0300 Message-ID: <20110622175306.GA2823@soloJazz.com> References: <87mxhaunsi.fsf@ucl.ac.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from eggs.gnu.org ([140.186.70.92]:50677) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QZRc3-0005MZ-Ie for emacs-orgmode@gnu.org; Wed, 22 Jun 2011 13:53:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QZRc1-0004m0-UG for emacs-orgmode@gnu.org; Wed, 22 Jun 2011 13:53:15 -0400 Received: from oproxy7-pub.bluehost.com ([67.222.55.9]:37610) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1QZRc1-0004lU-IN for emacs-orgmode@gnu.org; Wed, 22 Jun 2011 13:53:13 -0400 Received: from r186-48-221-4.dialup.adsl.anteldata.net.uy ([186.48.221.4] helo=iso.palmas.net) by box519.bluehost.com with esmtpa (Exim 4.69) (envelope-from ) id 1QZRbx-0007Av-39 for emacs-orgmode@gnu.org; Wed, 22 Jun 2011 11:53:09 -0600 Content-Disposition: inline In-Reply-To: <87mxhaunsi.fsf@ucl.ac.uk> 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 Hi, The documentation for #+call is rather confusing: It is also possible to evaluate named code blocks from anywhere in an Org-mode buffer or an Org-mode table. #+call (or synonymously #+function or #+lob) lines can be used to remotely execute code blocks... Because aparently #+call only works on on a line by itself. Check the following in ob-lob.el: #+begin_src emacs-lisp (defconst org-babel-lob-one-liner-regexp (concat "^\\([ \t]*\\)#\\+\\(?:" (mapconcat #'regexp-quote org-babel-lob-call-aliases "\\|") "\\):[ \t]+\\([^\(\)\n]+?\\)\\(\\[\\(.*\\)\\]\\|\\(\\)\\)" "\(\\([^\n]*\\)\)\\(\\[.+\\]\\|\\)[ \t]*\\([^\n]*\\)") "Regexp to match calls to predefined source block functions.") #+end_src This only matches whitespace at the beginning of line followed by #+call (or lob or function), unlike the embedded calls of the form src_{body} which can be inlined. Regards, .j. On Wed, Jun 22, 2011 at 12:07:57PM +0100, Eric S Fraga wrote: > I have been playing with org babel for putting results inline within an > exported latex file. A simple example is here: > > --8<---------------cut here---------------start------------->8--- > * testing inline evaluation of babel source blocks > > #+srcname: benzene-chlorobenzene-relative-volatility > #+begin_src octave :exports none :results output raw :var T=25 > format bank > pb = 10^(6.89272 - 1203.531/(T+219.888)); > pc = 10^(7.10690 - 1500.0 /(T+224.000)); > alpha = pb/pc; > disp(alpha) > #+end_src > > 1. The first step is to evaluate the relative volatility at \(T=25 ^{\circ} C\): > #+call: benzene-chlorobenzene-relative-volatility[:results output raw](T=25) :exports results > > 2. Compare this to the value we get at 50 \(^{\circ}C\): > #+call: benzene-chlorobenzene-relative-volatility(T=50) :exports results > > 3. Next we use this value to draw an equilibrium curve. > > --8<---------------cut here---------------end--------------->8--- > > If I evaluate the code block, I get what I expect: > > ,---- > | #+results: benzene-chlorobenzene-relative-volatility > | 7.86 > `---- > > However, when I export the file, the #+call lines get wrapped in a > verbatim environment regardless of what or where I specify for > the :results header arguments. E.g.: > > ,---- > | \begin{enumerate} > | \item The first step is to evaluate the relative volatility at \(T=25 ^{\circ} C\): > | > | > | \begin{verbatim} > | 7.86 > | \end{verbatim} > | > | \item Compare this to the value we get at 50 \(^{\circ}C\): > | > | > | \begin{verbatim} > | 6.32 > | \end{verbatim} > `---- > > What am I doing wrong? I have tried various permutations of the > placement of the :results header and various options for it but do not > seem to have hit on the right combination. > > Ideally, I would like the number to appear completely inline with the > text the precedes and follows the #+call statement. I would prefer to > not have a new paragraph started, for instance. > > On a related note, although the manual seems to indicate that "raw" and > "org" are synonymous, they behave differently when evaluating a code > block with the latter encapsulating the output within #+begin_org > and #+end_org. The behaviour is fine but maybe the documentation, > assuming I have understand things correctly, should be changed to > reflect the difference in behaviour? > > Thanks, > eric >