* org-babel R, export, and :result value raw
@ 2011-09-15 20:42 Christophe Rhodes
2011-09-15 21:12 ` Nick Dokos
2011-09-15 21:45 ` Eric Schulte
0 siblings, 2 replies; 3+ messages in thread
From: Christophe Rhodes @ 2011-09-15 20:42 UTC (permalink / raw)
To: emacs-orgmode
Hi,
Consider the following org-mode file, assuming that org-babel support
for emacs lisp and R is active:
--- begin ---
#+TITLE: Foo
#+begin_src emacs-lisp :exports results :results value raw
"[[file:foo.png]]"
#+end_src
#+results:
[[foo.png]]
#+begin_src R :exports results :results value raw
"[[file:bar.png]]"
#+end_src
#+results:
[[file:bar\.png]]
--- end ---
The problem is probably obvious from the above, but to be explicit: the
intent is to generate raw org-mode from the code blocks (this case is
hugely simplified from my actual application), producing links to images
which will then be part of the eventual exported document. For emacs
lisp, this works fine; for R, the path through files and specifically
org-babel-import-elisp-from-file / org-babel-string-read causes the
return value to be misinterpreted, introducing an extra backslash, and
therefore generating bogus export files.
(This used to work for my use case in org-mode 7.4, and does not work in
org-mode 7.6; I looked at HEAD to see if I could identify a fix, but did
not find one -- I'm sorry if I missed it)
Thanks,
Christophe
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: org-babel R, export, and :result value raw
2011-09-15 20:42 org-babel R, export, and :result value raw Christophe Rhodes
@ 2011-09-15 21:12 ` Nick Dokos
2011-09-15 21:45 ` Eric Schulte
1 sibling, 0 replies; 3+ messages in thread
From: Nick Dokos @ 2011-09-15 21:12 UTC (permalink / raw)
To: Christophe Rhodes; +Cc: nicholas.dokos, emacs-orgmode
Christophe Rhodes <csr21@cantab.net> wrote:
> Hi,
>
> Consider the following org-mode file, assuming that org-babel support
> for emacs lisp and R is active:
>
> --- begin ---
> #+TITLE: Foo
>
> #+begin_src emacs-lisp :exports results :results value raw
> "[[file:foo.png]]"
> #+end_src
>
> #+results:
> [[foo.png]]
>
> #+begin_src R :exports results :results value raw
> "[[file:bar.png]]"
> #+end_src
> #+results:
> [[file:bar\.png]]
> --- end ---
>
> The problem is probably obvious from the above, but to be explicit: the
> intent is to generate raw org-mode from the code blocks (this case is
> hugely simplified from my actual application), producing links to images
> which will then be part of the eventual exported document. For emacs
> lisp, this works fine; for R, the path through files and specifically
> org-babel-import-elisp-from-file / org-babel-string-read causes the
> return value to be misinterpreted, introducing an extra backslash, and
> therefore generating bogus export files.
>
> (This used to work for my use case in org-mode 7.4, and does not work in
> org-mode 7.6; I looked at HEAD to see if I could identify a fix, but did
> not find one -- I'm sorry if I missed it)
>
This bisects to the following commit:
--8<---------------cut here---------------start------------->8---
commit b6912331715c7da08927b3636b6721af5f5e0c41
Author: Eric Schulte <schulte.eric@gmail.com>
Date: Tue Mar 1 10:31:00 2011 -0700
ob: allow passing elisp vectors through to code blocks
* lisp/ob.el (org-babel-read): Pass elisp vectors through to code
blocks.
diff --git a/lisp/ob.el b/lisp/ob.el
index ea1c968..b0b5fb6 100644
--- a/lisp/ob.el
+++ b/lisp/ob.el
@@ -1913,16 +1913,15 @@ (defun org-babel-script-escape (str)
(defun org-babel-read (cell &optional inhibit-lisp-eval)
"Convert the string value of CELL to a number if appropriate.
-Otherwise if cell looks like lisp (meaning it starts with a \"(\"
-or a \"'\") then read it as lisp, otherwise return it unmodified
-as a string. Optional argument NO-LISP-EVAL inhibits lisp
-evaluation for situations in which is it not appropriate."
+Otherwise if cell looks like lisp (meaning it starts with a
+\"(\", \"'\", \"`\" or a \"[\") then read it as lisp, otherwise
+return it unmodified as a string. Optional argument NO-LISP-EVAL
+inhibits lisp evaluation for situations in which is it not
+appropriate."
(if (and (stringp cell) (not (equal cell "")))
(or (org-babel-number-p cell)
(if (and (not inhibit-lisp-eval)
- (or (equal "(" (substring cell 0 1))
- (equal "'" (substring cell 0 1))
- (equal "`" (substring cell 0 1))))
+ (member (substring cell 0 1) '("(" "'" "`" "[")))
(eval (read cell))
(progn (set-text-properties 0 (length cell) nil cell) cell)))
cell))
--8<---------------cut here---------------end--------------->8---
If I revert it, I get the 7.4 behavior.
The problem is that "[..." looks like a lisp vector to this function.
Nick
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: org-babel R, export, and :result value raw
2011-09-15 20:42 org-babel R, export, and :result value raw Christophe Rhodes
2011-09-15 21:12 ` Nick Dokos
@ 2011-09-15 21:45 ` Eric Schulte
1 sibling, 0 replies; 3+ messages in thread
From: Eric Schulte @ 2011-09-15 21:45 UTC (permalink / raw)
To: Christophe Rhodes; +Cc: emacs-orgmode
Hi Christophe,
This issue of result wrappers (e.g., raw org html) not playing well with
result types (e.g., vector, scalar) came up a couple of months ago on
this mailing list and was not resolved.
I've just pushed up a change which should fix this problem, along with
an R-specific fix so that R respects the "scalar" and "verbatim"
:results header arguments so that the following now works.
#+begin_src R :results raw scalar
"[[file:bar.png]]"
#+end_src
Best -- Eric
Christophe Rhodes <csr21@cantab.net> writes:
> Hi,
>
> Consider the following org-mode file, assuming that org-babel support
> for emacs lisp and R is active:
>
> --- begin ---
> #+TITLE: Foo
>
> #+begin_src emacs-lisp :exports results :results value raw
> "[[file:foo.png]]"
> #+end_src
>
> #+results:
> [[foo.png]]
>
> #+begin_src R :exports results :results value raw
> "[[file:bar.png]]"
> #+end_src
> #+results:
> [[file:bar\.png]]
> --- end ---
>
> The problem is probably obvious from the above, but to be explicit: the
> intent is to generate raw org-mode from the code blocks (this case is
> hugely simplified from my actual application), producing links to images
> which will then be part of the eventual exported document. For emacs
> lisp, this works fine; for R, the path through files and specifically
> org-babel-import-elisp-from-file / org-babel-string-read causes the
> return value to be misinterpreted, introducing an extra backslash, and
> therefore generating bogus export files.
>
> (This used to work for my use case in org-mode 7.4, and does not work in
> org-mode 7.6; I looked at HEAD to see if I could identify a fix, but did
> not find one -- I'm sorry if I missed it)
>
> Thanks,
>
> Christophe
>
>
--
Eric Schulte
http://cs.unm.edu/~eschulte/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-09-15 21:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-15 20:42 org-babel R, export, and :result value raw Christophe Rhodes
2011-09-15 21:12 ` Nick Dokos
2011-09-15 21:45 ` Eric Schulte
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).