From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daniel Gerber Subject: Re: [PATCH] Strip text properties from string code block arguments Date: Wed, 08 Jan 2014 11:03:14 +0100 Message-ID: <52CD2262.3040501@gmail.com> References: <52CC38B1.7060107@gmail.com> <87y52rem1x.fsf@bzg.ath.cx> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:54749) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W0pzc-0003tA-Is for emacs-orgmode@gnu.org; Wed, 08 Jan 2014 05:04:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W0pzV-0006lg-4h for emacs-orgmode@gnu.org; Wed, 08 Jan 2014 05:04:08 -0500 In-Reply-To: <87y52rem1x.fsf@bzg.ath.cx> 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: Bastien , emacs-orgmode@gnu.org Hi Bastien, On 07/01/2014 18:31, Bastien wrote: > Daniel Gerber writes: > >> This change in org-babel-python-var-to-python makes python code blocks >> accept a string with text properties (as one gets when referring >> another code block). I guess there should be something similar for >> other languages. > I don't understand why properties would be a problem here. > Can you elaborate a bit on this? The problem is that formatting as s-expression puts them into python code. Here is what I want to do. First edit a query string: #+RESULTS: query #+BEGIN_SRC sparql select * where { ?x rdf:label "x\\r"@en } #+END_SRC (The trick of naming this block with #+results: is so that: 1. org-edit-src-code uses the right mode 2. the code block is not evaluated 3. its body is passed as a string to other code blocks. For lack of a better idea...) Use the query string verbatim in another language: #+NAME: py #+BEGIN_SRC python :var q=query # return some_graph.query(q) return q #+END_SRC But now calling py() or tangling would give a syntax error because #+BEGIN_SRC elisp :var q=query (org-babel-python-var-to-python q) #+END_SRC #+RESULTS: : ""#("select * : where { ?x rdf:label \"x\\\\r\"@en } : " 0 9 (face org-block font-lock-multiline t wrap-prefix #(" " 0 2 (face org-indent)) line-prefix nil font-lock-fontified t fontified t) 9 30 (face org-block font-lock-multiline t wrap-prefix #(" " 0 2 (face org-indent)) line-prefix nil font-lock-fontified t fontified t) 30 35 (face org-block font-lock-multiline t font-lock-fontified t wrap-prefix #(" " 0 2 (face org-indent)) line-prefix nil fontified t) 35 40 (face org-block font-lock-multiline t font-lock-fontified t wrap-prefix #(" " 0 2 (face org-indent)) line-prefix nil fontified t) 40 41 (face org-block font-lock-multiline t wrap-prefix #(" " 0 2 (face org-indent)) line-prefix nil font-lock-fontified t fontified t) 41 42 (face org-block font-lock-multiline t wrap-prefix #(" " 0 2 (face org-indent)) line-prefix nil font-lock-fontified t fontified t))"" If org-babel-python-var-to-python does #+BEGIN_SRC elisp :var q=query (format "%S" (substring-no-properties q)) #+END_SRC #+RESULTS: : "select * : where { ?x rdf:label \"x\\\\r\"@en } : " then both evaluation and tangling work fine: #+CALL: py() #+RESULTS: : select * : where { ?x rdf:label "x\\r"@en } Best, Daniel