From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Dokos Subject: Re: org-babel R, export, and :result value raw Date: Thu, 15 Sep 2011 17:12:23 -0400 Message-ID: <12816.1316121143@alphaville.dokosmarshall.org> References: <874o0dzge2.fsf@cantab.net> Reply-To: nicholas.dokos@hp.com Return-path: Received: from eggs.gnu.org ([140.186.70.92]:33427) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R4JET-0002Ob-7o for emacs-orgmode@gnu.org; Thu, 15 Sep 2011 17:12:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R4JER-0006lf-K1 for emacs-orgmode@gnu.org; Thu, 15 Sep 2011 17:12:29 -0400 Received: from g4t0016.houston.hp.com ([15.201.24.19]:21845) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R4JER-0006lQ-Et for emacs-orgmode@gnu.org; Thu, 15 Sep 2011 17:12:27 -0400 In-Reply-To: Message from Christophe Rhodes of "Thu, 15 Sep 2011 21:42:45 BST." <874o0dzge2.fsf@cantab.net> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Christophe Rhodes Cc: nicholas.dokos@hp.com, emacs-orgmode@gnu.org Christophe Rhodes 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 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