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: Sébastien Miquel
Subject: Re: [PATCH] Add :noweb-prefix and :noweb-trans babel header arguments
Date: Fri, 29 Apr 2022 14:27:09 +0000

Hi,

Ihor Radchenko writes:
prin1-to-string is too specific and only solves a single use-case.
prin1-to-string is actually universal in a way, since any other
manipulation can then be achieved with

: (setq var (do-something <<nw>>))

at least as long as you're tangling to a programming language, that
can read lisp strings.
Consider the following example:

#+BEGIN_SRC emacs-lisp :noweb yes :tangle yes :noweb-prefix no :noweb-trans prin1-to-string
<<preamble>>
(setq latex-header <<nw>>)
#+END_SRC

There are two noweb references here. Setting source block-wide
:noweb-trans is not helpful because the first reference will be
incorrectly filtered through prin1-to-string.
Indeed. Originally I had thought of adding a new syntax <<"nw">> to
insert a string representation. I've attached a new patch, that does
this instead of introducing :noweb-trans. Now that I think of the
universality of prin1-to-string, I actually like it slightly better
than :noweb-trans. It would break existing "nw"-like noweb references.


Of course, one can work around this easily enough by using two blocks.
I'd rather introduce a new syntax to transform the noweb reference
inline. Something like

#+BEGIN_SRC emacs-lisp :noweb yes :tangle yes :noweb-prefix no
<<preamble>>
(setq latex-header <<(prin1-to-string nw)>>)
#+END_SRC
You'd need to only allow a single function call with only one
argument, or use something like <<(prin1-to-string <<nw>>)>>. The
change would be much more complex than what I propose, for maybe
little benefit.
[...]
This sounds a bit confusing. I would also add an example where it is
useful to set :noweb-prefix to no.

I've added such an example in the revised patch attached.

Thanks for the feedback.

Regards,

-- 
Sébastien Miquel

Attachment: 0001-ob-core.el-Add-noweb-prefix-noweb-trans-babel-header.patch
Description: Text Data

Attachment: 0001-ob-core.el-noweb-prefix-header-argument-and-nw-synta.patch
Description: Text Data


reply via email to

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