Sébastien Miquel <sebastien.miq...@posteo.eu> writes: > Ihor Radchenko writes: >> Can you provide more concrete examples? >> >>> Some drawbacks: >>> + doesn't work for all languages (does work for LaTeX) >> Which languages do not work? > Most languages do not work. Using your proposed solution, what I'm > trying to do is > > #+name:javascript-header > #+begin_src javascript :tangle no > some javascript, with \ and " to be escaped > #+end_src > > #+name: string-escape > #+begin_src emacs-lisp :var str="" :tangle no > (prin1-to-string (string-trim-right str)) > #+end_src > > #+begin_src emacs-lisp :noweb yes :tangle yes > (setq javascript-header <<string-escape(str=javascript-header)>>) > #+end_src > > If you replace javascript with latex, it happens to work, because when > org executes a latex block, it prints its content. > > The goal is to tangle to some lisp code whose purpose is to generate > LaTeX/javascript code. Quite niche admittedly, though as you showed, > it could also be used to string-escape documentation.
Thanks for providing an example! The current behaviour of :var foo=name-of-src-block is assigning result of evaluation. However, this behaviour is actually not documented. 16.4 Environment of a Code Block section of the manual only documents uses like #+BEGIN_SRC emacs-lisp :var length=table-length() or #+BEGIN_SRC emacs-lisp :var input=double(input=1) Currently, #+BEGIN_SRC emacs-lisp :var length=table-length is the same with #+BEGIN_SRC emacs-lisp :var length=table-length() Given that #+BEGIN_SRC emacs-lisp :var x=literal-example inserts the literal contents of the example block, I am voting to change the current undocumented behaviour for assigning the code block references. This will make the discussed example work while not restricting the existing features. WDYT? Best, Ihor