From mboxrd@z Thu Jan 1 00:00:00 1970 From: Roger Mason Subject: Re: Table formula from code block Date: Tue, 24 Jan 2017 08:40:51 -0330 Message-ID: References: <871svuf0dc.fsf@luisa.c0t0d0s0.de> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:48715) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cVzwG-0006F8-DH for emacs-orgmode@gnu.org; Tue, 24 Jan 2017 07:11:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cVzwD-0002ip-2i for emacs-orgmode@gnu.org; Tue, 24 Jan 2017 07:11:04 -0500 Received: from simone.ucs.mun.ca ([134.153.232.76]:57484) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cVzwC-0002ht-PR for emacs-orgmode@gnu.org; Tue, 24 Jan 2017 07:11:01 -0500 In-Reply-To: <871svuf0dc.fsf@luisa.c0t0d0s0.de> (Michael Welle's message of "Mon, 23 Jan 2017 13:04:47 +0100") 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" To: Michael Welle Cc: emacs-orgmode@gnu.org Hello Roland and Michael, Thank you both for looking at this. Roland Everaert writes: > I will try to look at how I used org-sbe, but I do remind that I had to do the following (exerpt from a post on > the list by me on the same subjet): > > "It works. But I had to set some headers in the code block itself as following: > > :exports results :results value" I will give that a try, thank you. Michael Welle writes: > I think there are several problems, starting with BEGIN_SRC sh and some > more. But fixing them doesn't bring success. I even have trouble to get > a minimal example to work: > > #+NAME: foo > #+BEGIN_SRC emacs-lisp > > (+ 4 4) > #+END_SRC > > > | bar | foo | > |--------+--------| > | 42 | #ERROR | > > #+TBLFM: $2='(org-sbe "foo")::$1=42 > > I'm not sure, what the problem is. Looking at org-sbe there is > something, I don't understand. In the end org-babel-execute-src-block is > called. That executes the _current_ source code block. But I don't > understand, how foo (in this example) becomes the current source code > block. Can someone explain, please? Is there a side effect, I don't see? > Or maybe a regression? I have experimented some more and discovered that I can get the code to work if I wrap the table entries in quotes, i.e. making them into explicit strings: #+tblname: display-results | skribilo path | infile | engine | To Engine | To Typeset | |-------------------------+--------------------+-----------+-----------+------------| | "/opt/skribilo-git/bin" | "skribilo-input-1" | "context" | Success | Success | #+TBLFM: $4='(org-sbe "skribilo_to_engine" (path $1) (infile $2) (engine $3) )::$5='(org-sbe "engine_to_typeset" (path $1) (infile $2) (engine $3) ) Maybe emacs has a means of doing that wrapping, but the things I tried (like concatenating the quotes with the table entry with (concat...)) did not work. I see that in your example you refer to the column heading in the #+TBLFM line. In my working code I refer to the columns by number ($1, $2 etc). I'm appending the current version of the code, in case anyone is interested. Cheers, Roger =========================================================================== # RunTests.org --- # Author: rmason@cryptoperthite.esd.mun.ca # Version: $Id: Results.org,v 0.0 2016/12/07 15:01:38 rmason Exp$ #+TITLE: Skribe Input Format: Whatever #+OPTIONS: toc:nil num:nil author:nil #+LATEX_HEADER: \usepackage{natbib} \usepackage{apalike} \usepackage{lineno} #+LATEX_HEADER: \usepackage{sectsty} \usepackage{setspace} \usepackage{parskip} # Turned OFF #+LATEX: \linenumbers \doublespacing \usepackage{ulem} \usepackage{titlecaps} #+LATEX: \subsubsectionfont{\itshape} # #+LATEX: \subsectionfont{\titlecap} -- buggers up en-dashes in # subsection titles #+LATEX: \sectionfont{\MakeUppercase} * Setup :exports none #+BEGIN_SRC emacs-lisp :results none :exports none (setq org-confirm-babel-evaluate nil) #+END_SRC I'd like a default input filename, but I could not get this to do anything. #+PROPERTY: infile "skribilo-input" * The input document When I call this with name =skribilo-input= rather than tangling the file, Org opens a Geiser REPL and the processing fails. I'm not sure Guile can process the Skribe syntax. #+NAME: skribilo-input #+BEGIN_SRC scheme :tangle "skribilo-input.skb" ; Whatever.skb #+END_SRC * The scripts ** Skribilo to supported engine format #+NAME: skribilo_to_engine #+BEGIN_SRC bash :results output replace :var path="" :var engine="" :var infile="" skribilo=$path/skribilo rm -rf $engine; mkdir -p $engine result="Failed" $skribilo -t $engine -o $engine/$infile.$engine $infile.skb [ "$(ls -A $engine)" ] && result="Success" if [ -e "setup.tex" ] then mv setup.tex $engine/ fi echo "$result" #+END_SRC *** Example #+CALL: skribilo_to_engine(engine="context", path="/opt/skribilo-git/bin", infile="skribilo-input") ** Engine to typeset document #+NAME: engine_to_typeset #+BEGIN_SRC bash :results output replace :var engine="" :var infile="" outfile=$infile"_"$engine wd=$(pwd) result="Failure" if [ $engine = "context" ]; then cd context source /opt/context/tex/setuptex 2>&1 > /tmp/log context --purgeall --result="$outfile.pdf" "$infile.$engine" 2>&1 > /tmp/log [ -e "$outfile.pdf" ] && result="Success" elif [ $engine = "latex" ]; then cd latex pdflatex $infile.$engine 2>&1 > /tmp/log mv $infile.pdf $outfile.pdf [ -e "$outfile.pdf" ] && result="Success" elif [ $engine = "lout" ];then cd lout lout $infile.$engine > $outfile.ps ps2pdf $outfile.ps [ -e "$outfile.pdf" ] && result="Success" else result="n.a." fi cd $wd echo "$result" #+END_SRC *** Example #+CALL: engine_to_typeset(engine="context", infile="skribilo-input") * The result table Should be able to run the tests from the table. See http://orgmode.org/worg/org-contrib/babel/intro.html#arguments-to-source-code-blocks for using a table as input to a source block. This only works if the engine entries are explicit strings. There must be a better way. It ought to be possible to set the =path= and =infile= variables globally. I tried using =#+PROPERTY:= (see above) to no avail. I searched this: 'org-mode set default value for source block input variables' but did not finish reviewing the results. The tests for Success are not very robust. #+tblname: results | skribilo path | infile | engine | To Engine | To Typeset | |-------------------------+------------------+-----------+-----------+------------| | "/opt/skribilo-git/bin" | "skribilo-input" | "context" | | | | "/opt/skribilo-git/bin" | "skribilo-input" | "latex" | | | | "/opt/skribilo-git/bin" | "skribilo-input" | "lout" | | | | "/opt/skribilo-git/bin" | "skribilo-input" | "html" | | | | "/opt/skribilo-git/bin" | "skribilo-input" | "info" | | | | "/opt/skribilo-git/bin" | "skribilo-input" | "xml" | | | | | | | | | #+TBLFM: $4='(org-sbe "skribilo_to_engine" (path $1) (infile $2) (engine $3) )::$5='(org-sbe "engine_to_typeset" (path $1) (infile $2) (engine $3) ) ===========================================================================