emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Greg Minshall <minshall@umich.edu>
To: Org Mode Mailing List <emacs-orgmode@gnu.org>
Subject: Re: babel awk with table input: Code block produced no output.
Date: Sun, 05 Aug 2012 16:57:44 -0700	[thread overview]
Message-ID: <72741.1344211064@gregair> (raw)
In-Reply-To: Your message of "Thu, 02 Aug 2012 09:01:01 EDT." <54085.1343912461@gregair>

hi.  i did a bit of poking around.  here are my findings, but i'm not
conversant enough with the semantics and interconnectivity of org-mode
to know what should be done.

to summarize: if a Babel awk script returns something that starts out
with a left paren ("("), i get "Code block returned no value".

basically, org-babel-execute:awk calls org-babel-import-elisp-from-file:
which calls org-babel-string-read [1] with each cell of the result.

org-babel-string-read calls org-babel-read.  org-babel-read
looks to see if the first character of the cell is one of {[,(,',`} and,
if it is, tries to evaluate the cell as e-lisp.  in my case (below),
what is in the cell is "(minimal)" and since there is no minimal
function in e-lisp, an error is thrown.

so, the first question is, are the semantics of parsing results such
that random e-lisp-looking code should be executed?  (this seems
dangerous, but may nevertheless be the intended semantics.)  if one did
*not* want that behavior, one can call org-babel-read with the
inhibit-lisp-eval parameter 't, which causes it to *not* try to execute
any embedded lisp-looking code [2].

the error that eval throws is caught by
org-babel-import-elisp-from-file, which then just silently returns a
nil.  the second question is, should it report an error to the user?

cheers, Greg Minshall

----

> hi.  it appears that a left or right paren in an entry in a table makes
> awk not execute.  here's an example (change ":stdin fails" to ":stdin
> works" to see it work).  cheers, Greg
> ----
> #+tblname: fails
> | proto          | no c code                   |            |
> | pscl           | c code, just fine           |            |
> | quadprog       | (minimal) c code, just fine |            |
> 
> #+tblname: works
> | proto          | no c code                   |            |
> | pscl           | c code, just fine           |            |
> | quadprog       | minimal c code, just fine   |            |
> 
> #+begin_src awk :stdin fails
>   BEGIN {
>       print "starting"
>   }
>   {
>       print $0
>   }
> #+end_src
----

[1] in spite of its documentation, i'm not sure what
org-babel-string-read does.  i thought it was removing quotation marks
from strings (but wasn't sure why).  but, running this in *scratch*
gives:
----
(org-babel-string-read "this is \"a\" test")
"a"
----
rather than "this is a test", as i had assumed.  maybe that was a bogus
test?

[2] changing org-babel-string-read to call org-babel-read with
inhibit-lisp-eval 't causes *my code* to work.  my code *also* works if
i say ":results output" or ":results scalar"; i will defensively use one
of these for my code.

  parent reply	other threads:[~2012-08-05 23:57 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-30  2:26 are super-hidden technical blocks required? Torsten Wagner
2012-07-30  7:26 ` Bastien
2012-07-30 10:27   ` Rasmus
2012-07-30 14:27     ` Russell Adams
     [not found]   ` <CAPaq-gMV-+n6OAN4PnBsh1eiJ5wA=Ns_m_qwHqz1pxbOxeYCCQ@mail.gmail.com>
2012-07-31  2:04     ` Fwd: " Torsten Wagner
2012-07-30 14:42 ` Ivy Foster
2012-07-30 15:23   ` Jonathan Leech-Pepin
2012-07-31 13:23     ` Robert Horn
2012-07-31 13:47       ` Torsten Wagner
2012-08-04 18:10       ` Ilya Shlyakhter
2012-08-05  9:16         ` Bastien
2012-08-05 20:04           ` Ilya Shlyakhter
2012-08-05 22:20             ` Nicolas Goaziou
2012-08-05 22:50               ` Ilya Shlyakhter
2012-08-06  2:46                 ` Torsten Wagner
2012-08-06  3:01                   ` Ilya Shlyakhter
2012-08-06 12:12                     ` Jonathan Leech-Pepin
2012-08-06 17:25                       ` Ilya Shlyakhter
2012-08-06 18:16         ` Allen S. Rout
2012-08-06 19:01           ` Michael Brand
2012-08-07 21:29           ` Ilya Shlyakhter
2012-07-31  2:48 ` Torsten Wagner
2012-08-01 13:29   ` Bastien
2012-08-02  1:19     ` Torsten Wagner
2012-08-06 15:02       ` Christopher J. White
2012-08-01 17:11   ` Achim Gratz
2012-08-01 18:39     ` Bernt Hansen
2012-08-01 18:49       ` Achim Gratz
2012-08-02  1:16     ` Torsten Wagner
2012-08-02 15:10       ` Bastien
2012-08-07 21:33         ` Ilya Shlyakhter
2012-08-02 13:01   ` babel awk with table input: Code block produced no output Greg Minshall
2012-08-02 13:21     ` Sebastien Vauban
2012-08-03  2:08     ` [BUG] Traceback on Org-Export Luis Anaya
2012-08-03  7:19       ` Bastien
2012-08-03 10:27         ` Luis Anaya
2012-08-04 13:06           ` Achim Gratz
2012-08-04 14:13             ` Achim Gratz
2012-08-04 17:58             ` Bastien
2012-08-04 21:07               ` Achim Gratz
2012-08-05  9:44                 ` Bastien
2012-08-05 15:44                   ` Achim Gratz
2012-08-03 10:43         ` Luis Anaya
2012-08-03 11:17           ` Giovanni Ridolfi
2012-08-03 11:32             ` Luis Anaya
2012-08-03 14:34               ` Nick Dokos
2012-08-03 20:09           ` Achim Gratz
2012-08-05 23:57     ` Greg Minshall [this message]
2012-08-06  1:36       ` babel awk with table input: Code block produced no output Thomas S. Dye
2012-08-06  4:59         ` Greg Minshall
2012-08-06 15:37       ` Change: no longer automatically evaluate embedded elisp in code block output Was: " Eric Schulte
2012-08-08  5:00         ` Greg Minshall
2012-08-07  3:12 ` are super-hidden technical blocks required? Torsten Wagner
2012-08-07 10:23   ` Bastien
2012-08-07 13:20     ` Torsten Wagner
2012-08-07 13:39       ` Christopher J. White
2012-08-07 14:11         ` Torsten Wagner
2012-08-07 14:30           ` Robert Horn
2012-08-14  9:58       ` Bastien

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

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=72741.1344211064@gregair \
    --to=minshall@umich.edu \
    --cc=emacs-orgmode@gnu.org \
    /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 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).