From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: Chaining strings between babel blocks: why so many '\'? Date: Wed, 26 Mar 2014 23:19:35 +0100 Message-ID: <87bnwstxfs.fsf@gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:56184) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WSwAD-0003o3-Tl for emacs-orgmode@gnu.org; Wed, 26 Mar 2014 18:19:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WSwA8-0004VY-8H for emacs-orgmode@gnu.org; Wed, 26 Mar 2014 18:19:13 -0400 Received: from mail-wi0-x230.google.com ([2a00:1450:400c:c05::230]:65300) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WSwA8-0004ST-1u for emacs-orgmode@gnu.org; Wed, 26 Mar 2014 18:19:08 -0400 Received: by mail-wi0-f176.google.com with SMTP id r20so5251037wiv.9 for ; Wed, 26 Mar 2014 15:19:06 -0700 (PDT) In-Reply-To: (Alan Schmitt's message of "Wed, 26 Mar 2014 22:59:42 +0100") 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: Alan Schmitt Cc: emacs-orgmode Hello, Alan Schmitt 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. Regards, -- Nicolas Goaziou