emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Peter Neilson" <neilson@windstream.net>
To: emacs-orgmode@gnu.org
Subject: Re: Chaining strings between babel blocks: why so many '\'?
Date: Wed, 26 Mar 2014 19:35:00 -0400	[thread overview]
Message-ID: <op.xdcrsmkhrns8nc@localhost.localdomain> (raw)
In-Reply-To: <87bnwstxfs.fsf@gmail.com>

On Wed, 26 Mar 2014 18:19:35 -0400, Nicolas Goaziou <n.goaziou@gmail.com>  
wrote:

> Hello,
>
> Alan Schmitt <alan.schmitt@polytechnique.org> writes:
>
>> I've been playing with block chaining to generate some dot file then to
>> export then as images. I had a little trouble finding the number of '\'
>> I need to put in front of a quote if I want the quote to be quoted. Here
>> is a way to make it work:
>>
>> #+name: foo
>> #+begin_src emacs-lisp :exports none
>> "bar [label = \"\\\\\"test1\\\\\"\"]\nbaz [label =  
>> \"\\\\\"test2\\\\\"\"]"
>> #+end_src
>>
>> #+results: foo
>> : bar [label = "\\"test1\\""]
>> : baz [label = "\\"test2\\""]
>>
>> #+begin_src dot :file ~/tmp/test-dot.png :var input=foo :exports results
>> graph {
>>   $input
>> }
>> #+end_src
>>
>> My question is: why can't I simply use this:
>>
>> #+name: foo
>> #+begin_src emacs-lisp :exports none
>> "bar [label = \"\\\"test1\\\"\"]\nbaz [label = \"\\\"test2\\\"\"]"
>> #+end_src
>>
>> #+results: foo
>> : bar [label = "\"test1\""]
>> : baz [label = "\"test2\""]
>>
>> (I guess the answer is in the error in replace-regexp-in-string:
>> (error "Invalid use of `\\' in replacement text")
>> .)
>
> Indeed. This function, unless told not to, treats backslashes characters
> specially.
>
>> Would it be problematic to first transform every "\\" into a "\\\\" in
>> org-babel-expand-body:dot, before the call to
>> replace-regexp-in-string?
>
> I think `replace-regexp-in-string' should be called with a non-nil
> LITERAL argument in this case.

Maybe someone (neilson runs and hides!) should write a tool that allows  
construction of C++11-style raw string literals that would  
auto-transmogrify into the backslash mess that elisp requires.

  reply	other threads:[~2014-03-26 23:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-26 21:59 Chaining strings between babel blocks: why so many '\'? Alan Schmitt
2014-03-26 22:19 ` Nicolas Goaziou
2014-03-26 23:35   ` Peter Neilson [this message]
2014-03-27 12:41   ` Alan Schmitt
2014-03-29 11:10     ` Alan Schmitt
2014-04-16 15:37       ` Bastien
2014-04-16 18:01         ` Alan Schmitt

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=op.xdcrsmkhrns8nc@localhost.localdomain \
    --to=neilson@windstream.net \
    --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).