From: Roger Mason <rmason@mun.ca>
To: Michael Welle <mwe012008@gmx.net>
Cc: emacs-orgmode@gnu.org
Subject: Re: Table formula from code block
Date: Tue, 24 Jan 2017 08:40:51 -0330 [thread overview]
Message-ID: <y65wpdk8xpw.fsf@mun.ca> (raw)
In-Reply-To: <871svuf0dc.fsf@luisa.c0t0d0s0.de> (Michael Welle's message of "Mon, 23 Jan 2017 13:04:47 +0100")
Hello Roland and Michael,
Thank you both for looking at this.
Roland Everaert <reveatwork@gmail.com> 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 <mwe012008@gmx.net> 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) )
===========================================================================
next prev parent reply other threads:[~2017-01-24 12:11 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-22 12:27 Table formula from code block Roger Mason
2017-01-23 12:04 ` Michael Welle
2017-01-24 12:10 ` Roger Mason [this message]
2017-01-24 13:07 ` Michael Welle
2017-01-24 12:14 ` Michael Welle
[not found] ` <fbefc85e10fc401ebab2f7ef3794eade@HE1PR01MB1898.eurprd01.prod.exchangelabs.com>
2017-01-24 9:04 ` Eric S Fraga
2017-01-24 10:52 ` Michael Welle
[not found] ` <a780781601084f15802822fade909e25@HE1PR01MB1898.eurprd01.prod.exchangelabs.com>
2017-01-24 11:43 ` Eric S Fraga
2017-01-24 13:38 ` Michael Welle
2017-01-24 14:14 ` Michael Welle
[not found] ` <3b626627d0e74bd69bcf3a7941acf9f8@HE1PR01MB1898.eurprd01.prod.exchangelabs.com>
2017-01-24 16:13 ` Eric S Fraga
2017-01-25 14:19 ` Michael Welle
2017-01-24 13:01 ` Michael Welle
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=y65wpdk8xpw.fsf@mun.ca \
--to=rmason@mun.ca \
--cc=emacs-orgmode@gnu.org \
--cc=mwe012008@gmx.net \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.