Hi, Would there be some interest in extending the noweb syntax to allow for string escaped expansion ? I've modified my setup so that if the noweb delimiter `<<` is preceded by a quote `"` then the expansion is string escaped (and the prefix isn't duplicated for each line). This allows the following. #+BEGIN_SRC latex :noweb-ref latex-ref \some \multiline \unescaped \latex \code #+END_SRC #+BEGIN_SRC emacs-lisp :noweb yes (setq my-latex-code "<<latex-ref>>\n") #+END_SRC I don't think there's any way to achieve such functionality currently. -- Sébastien Miquel
Sébastien Miquel <sebastien.miquel@posteo.eu> writes:
> #+BEGIN_SRC latex :noweb-ref latex-ref
> \some \multiline
> \unescaped \latex \code
> #+END_SRC
>
> #+BEGIN_SRC emacs-lisp :noweb yes
> (setq my-latex-code "<<latex-ref>>\n")
> #+END_SRC
>
> I don't think there's any way to achieve such functionality currently.
Just quickly, this works:
#+begin_src emacs-lisp :noweb yes
(setq my-latex-code "\
<<latex-ref>>
")
#+end_src
even if it isn't ideal.
--
Timothy
Timothy writes:
> Just quickly, this works:
>
> #+begin_src emacs-lisp :noweb yes
> (setq my-latex-code "\
> <<latex-ref>>
> ")
> #+end_src
I don't understand the purpose of your backslash, is it a typo ? With
or without it, this doesn't tangle to working lisp with my example.
The point of my proposal is to allow one to write unescaped latex in
the latex src block. (Mostly to avoid doubling every backslash). It is
quite the shame to have to write non latex code in a latex src block.
Regards,
--
Sébastien Miquel
Sébastien Miquel <sebastien.miquel@posteo.eu> writes:
> The point of my proposal is to allow one to write unescaped latex in
> the latex src block. (Mostly to avoid doubling every backslash). It is
> quite the shame to have to write non latex code in a latex src block.
Ahhh, sorry --- I focused on the wrong part of your example, the lack of
newlines and the noweb prefix/suffix.
An escaping option would be nice IMO, +1.
--
Timothy
Hi Sebastien, I have encountered issues with this before when trying to noweb code into a string that was code to be sent via ssh. I ended up switching to use typeset -f in bash in most cases now, but that is not possible for other languages. Some languages also have enough different types of syntax for strings that they can work around such cases, but again, not all do. One potential issue with this suggestion is how it would interact with multi-line blocks, because you can't have anything on the same starting line as the noweb expressions since it will be repeated in front of every subsequent line. This would also require each org-babel lang implementation to provide a method for correctly string-escaping the nowebbed values (in some cases e.g. shell this is decidedly non-trivial). With all of these things in mind, I would thus suggest not trying to overload the noweb operator for this purpose. Having a string escaped equivalent would be nice, but because it requires more than just a simple copy/paste into the buffer, it seems like it probably needs separate notation. Best, Tom