emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Add :noweb-prefix and :noweb-trans babel header arguments


From: Ihor Radchenko
Subject: Re: [PATCH] Add :noweb-prefix and :noweb-trans babel header arguments
Date: Sat, 30 Apr 2022 16:41:35 +0800

Sébastien Miquel <sebastien.miquel@posteo.eu> writes:

>> Other than :noweb-trans, the patch looks good for me. 
> Here's a patch with only the :noweb-prefix part. If applied, we can mark 
> this thread resolved.

Thanks! Applied on main as 2063596b9.

> Ihor Radchenko writes:
>> #+name: documentation
>> This is a sample function documentation.
>> Because there are "quotes", it must be escaped and cannot be directly
>> used as noweb-reference.
>>
>> #+name: doc-escape
>> #+begin_src emacs-lisp :var str="" :tangle no
>> (prin1-to-string (string-trim-right str))
>> #+end_src
>>
>> #+begin_src emacs-lisp :tangle yes
>> (defun test ()
>> <<doc-escape(str=documentation)>>
>> t)
>> #+end_src
>
> Nice ! Quite obscure and brittle (doesn't work if documentation is a 
> text src block) but I can use it nonetheless.

Well. It looks natural for me. Depends on what you are used to when
working with org babel.

Things are a bit more tricky for latex source blocks, but you can still
do

#+name: nw
#+BEGIN_SRC latex :tangle no
\usepackage{…}
\usepackage{…}
#+END_SRC

#+BEGIN_SRC emacs-lisp :noweb yes :tangle yes :noweb-prefix no
(setq latex-header <<doc-escape(str=nw)>>)
#+END_SRC

Of course, it would only work for source blocks with corresponding
ob-*.el library. But then again, why would you need to wrap things into
text source block when a simple paragraph is enough.

Best,
Ihor

Applied.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]