From: Daniel Gerber <daniel.g.gerber@gmail.com>
To: Bastien <bzg@gnu.org>, emacs-orgmode@gnu.org
Subject: Re: [PATCH] Strip text properties from string code block arguments
Date: Wed, 08 Jan 2014 11:03:14 +0100 [thread overview]
Message-ID: <52CD2262.3040501@gmail.com> (raw)
In-Reply-To: <87y52rem1x.fsf@bzg.ath.cx>
Hi Bastien,
On 07/01/2014 18:31, Bastien wrote:
> Daniel Gerber<daniel.g.gerber@gmail.com> 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
next prev parent reply other threads:[~2014-01-08 10:04 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-07 17:26 [PATCH] Strip text properties from string code block arguments Daniel Gerber
2014-01-07 17:31 ` Bastien
2014-01-07 19:21 ` Achim Gratz
2014-01-08 8:47 ` Bastien
2014-01-08 10:03 ` Daniel Gerber [this message]
2014-01-08 16:31 ` Bastien
2014-01-08 17:27 ` Daniel Gerber
2014-01-08 17:32 ` Bastien
2014-01-09 20:39 ` Achim Gratz
2014-01-12 11:43 ` Bastien
2014-01-12 16:35 ` Eric Schulte
2014-01-12 23:28 ` 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=52CD2262.3040501@gmail.com \
--to=daniel.g.gerber@gmail.com \
--cc=bzg@gnu.org \
--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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.