Re: [O] Table formula from code block

2017-01-25 Thread Michael Welle
Hello,

Eric S Fraga  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



Re: [O] Table formula from code block

2017-01-24 Thread Eric S Fraga
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


signature.asc
Description: PGP signature


Re: [O] Table formula from code block

2017-01-24 Thread Michael Welle
Hello,

Eric S Fraga  writes:

> On Tuesday, 24 Jan 2017 at 10:52, Michael Welle wrote:
>> Eric S Fraga  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




Re: [O] Table formula from code block

2017-01-24 Thread Michael Welle
Hello,

Roger Mason  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



Re: [O] Table formula from code block

2017-01-24 Thread Michael Welle
Hello,

Eric S Fraga  writes:

> On Tuesday, 24 Jan 2017 at 10:52, Michael Welle wrote:
>> Eric S Fraga  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



Re: [O] Table formula from code block

2017-01-24 Thread Eric S Fraga
On Tuesday, 24 Jan 2017 at 10:52, Michael Welle wrote:
> Eric S Fraga  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


signature.asc
Description: PGP signature


Re: [O] Table formula from code block

2017-01-24 Thread Michael Welle
Hello,

Eric S Fraga  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



Re: [O] Table formula from code block

2017-01-24 Thread Michael Welle
Hello,

Michael Welle  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



Re: [O] Table formula from code block

2017-01-24 Thread Roger Mason
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: rma...@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#argume

Re: [O] Table formula from code block

2017-01-24 Thread Michael Welle
Hello,

Eric S Fraga  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



Re: [O] Table formula from code block

2017-01-24 Thread Eric S Fraga
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


signature.asc
Description: PGP signature


Re: [O] Table formula from code block

2017-01-23 Thread Michael Welle
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



[O] Table formula from code block

2017-01-22 Thread Roger Mason
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)