[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] Table formula from code block

From: Roger Mason
Subject: Re: [O] Table formula from code block
Date: Tue, 24 Jan 2017 08:40:51 -0330
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (berkeley-unix)

Hello Roland and Michael,

Thank you both for looking at this.

Roland Everaert <address@hidden> 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 <address@hidden> 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)
> |  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


# RunTests.org --- 

# Author: address@hidden
# 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} 
#+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)

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


* The scripts
** Skribilo to supported engine format
#+NAME: skribilo_to_engine
#+BEGIN_SRC bash :results output replace :var path="" :var engine="" :var 

  rm -rf $engine; mkdir -p $engine

  $skribilo  -t $engine -o $engine/$infile.$engine $infile.skb
  [ "$(ls -A $engine)" ] && result="Success"

  if [ -e "setup.tex" ]
  mv setup.tex $engine/
  echo "$result"

*** Example
#+CALL: skribilo_to_engine(engine="context", path="/opt/skribilo-git/bin", 

** Engine to typeset document
#+NAME: engine_to_typeset
#+BEGIN_SRC bash :results output replace :var engine="" :var infile=""
  if [ $engine = "context" ]; then
      cd context
      source /opt/context/tex/setuptex 2>&1 > /tmp/log 
      context --purgeall --result="$outfile.pdf" "$infile.$engine" 2>&1 > 
      [ -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"

  cd $wd
  echo "$result"

*** Example
#+CALL: engine_to_typeset(engine="context", infile="skribilo-input")

* The result table
Should be able to run the tests from the table.  See
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) )


reply via email to

[Prev in Thread] Current Thread [Next in Thread]