* Table formula from code block @ 2017-01-22 12:27 Roger Mason 2017-01-23 12:04 ` Michael Welle [not found] ` <fbefc85e10fc401ebab2f7ef3794eade@HE1PR01MB1898.eurprd01.prod.exchangelabs.com> 0 siblings, 2 replies; 13+ messages in thread From: Roger Mason @ 2017-01-22 12:27 UTC (permalink / raw) To: emacs-orgmode Hello, I have these code blocks: ================================================================================ #+BEGIN_SRC sh :tangle "skribilo_to_engine.sh" #!/usr/local/bin/bash infile=$3 engine=$2 skribilo=$1/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 #+BEGIN_SRC sh :results none chmod u+x skribilo_to_engine.sh #+END_SRC #+NAME: skribilo_to_engine #+BEGIN_SRC sh :results output replace :var path="/opt/skribilo-git/bin" :var engine="" :var infile="Author_7960" ./skribilo_to_engine.sh $path $engine $infile #+END_SRC =============================================================================== I tangle the code block and make it executable. I think it should be possible to run the code blocks from the table, but it errors out: #+tblname: summaries | engine | To Engine | |---------+-----------| | context | #ERROR | #+TBLFM: $2='(org-sbe "skribilo_to_engine" (engine $1) ) (See http://orgmode.org/worg/org-contrib/babel/intro.html#arguments-to-source-code-blocks). What am I doing wrong? Thanks, Roger GNU Emacs 25.1.1 (i386-portbld-freebsd10.1, GTK+ Version 2.24.29) of 2016-11-04 Org mode version 9.0.3 (release_9.0.3-170-gfed1cf) ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Table formula from code block 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 2017-01-24 12:14 ` Michael Welle [not found] ` <fbefc85e10fc401ebab2f7ef3794eade@HE1PR01MB1898.eurprd01.prod.exchangelabs.com> 1 sibling, 2 replies; 13+ messages in thread From: Michael Welle @ 2017-01-23 12:04 UTC (permalink / raw) To: emacs-orgmode Hello, 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? Regards hmw ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Table formula from code block 2017-01-23 12:04 ` Michael Welle @ 2017-01-24 12:10 ` Roger Mason 2017-01-24 13:07 ` Michael Welle 2017-01-24 12:14 ` Michael Welle 1 sibling, 1 reply; 13+ messages in thread From: Roger Mason @ 2017-01-24 12:10 UTC (permalink / raw) To: Michael Welle; +Cc: emacs-orgmode 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) ) =========================================================================== ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Table formula from code block 2017-01-24 12:10 ` Roger Mason @ 2017-01-24 13:07 ` Michael Welle 0 siblings, 0 replies; 13+ messages in thread From: Michael Welle @ 2017-01-24 13:07 UTC (permalink / raw) To: emacs-orgmode Hello, Roger Mason <rmason@mun.ca> writes: [...] > #+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. There is a thread of Karl and me talking about that, maybe in last november or december. > 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). Uhm, no ;). Unfortunately the column and the script block share the same name in the example. That should be no problem, I changed that and still no success with current Org. Org 8 works as expected. Regards hmw ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Table formula from code block 2017-01-23 12:04 ` Michael Welle 2017-01-24 12:10 ` Roger Mason @ 2017-01-24 12:14 ` Michael Welle 1 sibling, 0 replies; 13+ messages in thread From: Michael Welle @ 2017-01-24 12:14 UTC (permalink / raw) To: emacs-orgmode Hello, Michael Welle <mwe012008@gmx.net> writes: ... > #+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. well, the docstring is a bit misleading, IMHO. Current source code block means that the function looks around to find a source code block. I though, it means the source code block 'I am in' at the moment. I've tracked it down to org-babel-check-confirm-evaluate so far. In the let*, export and eval are nil. The 5. element of info is nil, that means (goto-char (nth 5 info)) will barf. Hmm. Regards hmw ^ permalink raw reply [flat|nested] 13+ messages in thread
[parent not found: <fbefc85e10fc401ebab2f7ef3794eade@HE1PR01MB1898.eurprd01.prod.exchangelabs.com>]
* Re: Table formula from code block [not found] ` <fbefc85e10fc401ebab2f7ef3794eade@HE1PR01MB1898.eurprd01.prod.exchangelabs.com> @ 2017-01-24 9:04 ` Eric S Fraga 2017-01-24 10:52 ` Michael Welle ` (2 more replies) 0 siblings, 3 replies; 13+ messages in thread From: Eric S Fraga @ 2017-01-24 9:04 UTC (permalink / raw) To: emacs-orgmode [-- Attachment #1: Type: text/plain, Size: 572 bytes --] On Monday, 23 Jan 2017 at 12:04, Michael Welle wrote: > Hello, > > 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 Works fine for me with relatively recent org from git. -- : Eric S Fraga (0xFFFCF67D), Emacs 26.0.50.1, Org release_9.0.3-191-g7404e3 [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 162 bytes --] ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Table formula from code block 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 13:01 ` Michael Welle 2 siblings, 0 replies; 13+ messages in thread From: Michael Welle @ 2017-01-24 10:52 UTC (permalink / raw) To: emacs-orgmode Hello, Eric S Fraga <e.fraga@ucl.ac.uk> writes: > On Monday, 23 Jan 2017 at 12:04, Michael Welle wrote: >> Hello, >> >> 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 > > Works fine for me with relatively recent org from git. that's strange. I pulled last sunday. Regards hmw ^ permalink raw reply [flat|nested] 13+ messages in thread
[parent not found: <a780781601084f15802822fade909e25@HE1PR01MB1898.eurprd01.prod.exchangelabs.com>]
* Re: Table formula from code block [not found] ` <a780781601084f15802822fade909e25@HE1PR01MB1898.eurprd01.prod.exchangelabs.com> @ 2017-01-24 11:43 ` Eric S Fraga 2017-01-24 13:38 ` Michael Welle ` (2 more replies) 0 siblings, 3 replies; 13+ messages in thread From: Eric S Fraga @ 2017-01-24 11:43 UTC (permalink / raw) To: emacs-orgmode [-- Attachment #1: Type: text/plain, Size: 369 bytes --] On Tuesday, 24 Jan 2017 at 10:52, Michael Welle wrote: > Eric S Fraga <e.fraga@ucl.ac.uk> writes: >> Works fine for me with relatively recent org from git. > that's strange. I pulled last sunday. Well, I have just this minute updated and tried again. It still works for me. -- : Eric S Fraga (0xFFFCF67D), Emacs 26.0.50.1, Org release_9.0.3-262-g5210de [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 162 bytes --] ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Table formula from code block 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> 2 siblings, 0 replies; 13+ messages in thread From: Michael Welle @ 2017-01-24 13:38 UTC (permalink / raw) To: emacs-orgmode Hello, Eric S Fraga <e.fraga@ucl.ac.uk> writes: > On Tuesday, 24 Jan 2017 at 10:52, Michael Welle wrote: >> Eric S Fraga <e.fraga@ucl.ac.uk> writes: >>> Works fine for me with relatively recent org from git. >> that's strange. I pulled last sunday. > > Well, I have just this minute updated and tried again. It still works > for me. I must doing something wrong. But what? I've changed org-bbdb, but that shouldn't interfere. Regards hmw ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Table formula from code block 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> 2 siblings, 0 replies; 13+ messages in thread From: Michael Welle @ 2017-01-24 14:14 UTC (permalink / raw) To: emacs-orgmode Hello, Eric S Fraga <e.fraga@ucl.ac.uk> writes: > On Tuesday, 24 Jan 2017 at 10:52, Michael Welle wrote: >> Eric S Fraga <e.fraga@ucl.ac.uk> writes: >>> Works fine for me with relatively recent org from git. >> that's strange. I pulled last sunday. > > Well, I have just this minute updated and tried again. It still works > for me. ohschockschwerenot, I found it. I set org-confirm-babel-evaluate to a function that does look at the body of the code block and then decides if it should be executed without confirmation or not. I'm not sure, why that is a problem. In the case of the examples, the function returns t and that is the default value of o-c-b-evaluate. Regards hmw ^ permalink raw reply [flat|nested] 13+ messages in thread
[parent not found: <3b626627d0e74bd69bcf3a7941acf9f8@HE1PR01MB1898.eurprd01.prod.exchangelabs.com>]
* Re: Table formula from code block [not found] ` <3b626627d0e74bd69bcf3a7941acf9f8@HE1PR01MB1898.eurprd01.prod.exchangelabs.com> @ 2017-01-24 16:13 ` Eric S Fraga 2017-01-25 14:19 ` Michael Welle 0 siblings, 1 reply; 13+ messages in thread From: Eric S Fraga @ 2017-01-24 16:13 UTC (permalink / raw) To: emacs-orgmode [-- Attachment #1: Type: text/plain, Size: 675 bytes --] On Tuesday, 24 Jan 2017 at 14:14, Michael Welle wrote: > ohschockschwerenot, I found it. I set org-confirm-babel-evaluate to a > function that does look at the body of the code block and then decides > if it should be executed without confirmation or not. > > I'm not sure, why that is a problem. In the case of the examples, the > function returns t and that is the default value of o-c-b-evaluate. Interesting. I cannot help with this but I would be quite interested in seeing your function in case it's something I could use! Would it be possible to share? thanks, eric -- : Eric S Fraga (0xFFFCF67D), Emacs 26.0.50.1, Org release_9.0.3-241-gc3d67b [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 194 bytes --] ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Table formula from code block 2017-01-24 16:13 ` Eric S Fraga @ 2017-01-25 14:19 ` Michael Welle 0 siblings, 0 replies; 13+ messages in thread From: Michael Welle @ 2017-01-25 14:19 UTC (permalink / raw) To: emacs-orgmode Hello, Eric S Fraga <e.fraga@ucl.ac.uk> writes: > On Tuesday, 24 Jan 2017 at 14:14, Michael Welle wrote: >> ohschockschwerenot, I found it. I set org-confirm-babel-evaluate to a >> function that does look at the body of the code block and then decides >> if it should be executed without confirmation or not. >> >> I'm not sure, why that is a problem. In the case of the examples, the >> function returns t and that is the default value of o-c-b-evaluate. > > Interesting. I cannot help with this but I would be quite interested in > seeing your function in case it's something I could use! Would it be > possible to share? it's quite a hack. I don't want Org to evaluate source code blocks without confirmation. This could lead to all sorts of trouble. On the other hand, there are a few source code blocks, that I want to eval without confirmation. So I use this: (defun hmw/org-post-publish-export-confirm-evaluate (lang body) (not (string-match "^#post publish exporter" body))) (setq org-confirm-babel-evaluate 'hmw/org-post-publish-export-confirm-evaluate) A source code block looks like follows: #+BEGIN_SRC shell :exports results :shebang #!/bin/sh :var SRCDIR=(expand-file-name (plist-get plist :base-directory)) :var DESTDIR=(expand-file-name (plist-get plist :publishing-directory)) #post publish exporter ( echo "Starting esxwithforeman.org $(date)" cd ${SRCDIR} .... echo "Finish esxwithforeman.org $(date)" ) >> /tmp/c0t0d0s0_publish.log 2>&1 #+END_SRC As you can see, this is not a security feature, esp. now that I published it ;). Regards hmw ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Table formula from code block 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 13:01 ` Michael Welle 2 siblings, 0 replies; 13+ messages in thread From: Michael Welle @ 2017-01-24 13:01 UTC (permalink / raw) To: emacs-orgmode Hello, Eric S Fraga <e.fraga@ucl.ac.uk> writes: > On Monday, 23 Jan 2017 at 12:04, Michael Welle wrote: >> Hello, >> >> 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 > > Works fine for me with relatively recent org from git. I just tried the Org version, that comes with Emacs (8.2.10) and there the above example works as expected. Regards hmw ^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2017-01-25 15:03 UTC | newest] Thread overview: 13+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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 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
Code repositories for project(s) associated with this public inbox https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).