emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@gmail.com>
To: sebastien.miquel@posteo.eu
Cc: emacs-orgmode <emacs-orgmode@gnu.org>
Subject: Re: [PATCH] Add :noweb-prefix and :noweb-trans babel header arguments
Date: Thu, 28 Apr 2022 21:45:55 +0800	[thread overview]
Message-ID: <875ymt8goc.fsf@localhost> (raw)
In-Reply-To: <2dd9630a-c584-0702-62aa-393ad56c621e@posteo.eu>

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

> The attached patch adds support for two new babel header arguments:
> =:noweb-prefix= and =:noweb-trans=.
>
> =:noweb-prefix= can be set to =no= to disable the noweb prefix
> behaviour, where prefix characters are repeated when expanding a
> multiline noweb reference.

Thanks for the patch! The idea about :noweb-prefix looks useful.

> =:noweb-trans= can be set to =prin1-to-string= to insert a lisp string
> representing the content of the referenced src block.
>
> The goal is to allow one to use, say, a LaTeX src block to represent
> some LaTeX snippet to be tangled into a string in some lisp (or other)
> code. This isn't possible currently, and one has to manually string
> escape the LaTeX code.
> ...
> I've left undocumented the possibility of setting =:noweb-trans= to
> another function. I wonder if anyone can think of some other use.

prin1-to-string is too specific and only solves a single use-case.

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.

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

>  Noweb insertions honor prefix characters that appear before the noweb
> -syntax reference.  This behavior is illustrated in the following
> -example.  Because the =<<example>>= noweb reference appears behind the
> -SQL comment syntax, each line of the expanded noweb reference is
> -commented.  With:
> +syntax reference. This behavior can be turned off by setting the
> +=noweb-prefix= header argument to =no= and is illustrated in the
> +following example. Because the =<<example>>= noweb reference appears
> +behind the SQL comment syntax, each line of the expanded noweb
> +reference is commented. With:

This sounds a bit confusing. I would also add an example where it is
useful to set :noweb-prefix to no.
  
Best,
Ihor


  reply	other threads:[~2022-04-28 13:46 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-15 10:42 [PATCH] Add :noweb-prefix and :noweb-trans babel header arguments Sébastien Miquel
2022-04-28 13:45 ` Ihor Radchenko [this message]
2022-04-29 14:27   ` Sébastien Miquel
2022-04-30  6:05     ` Ihor Radchenko
2022-04-30  7:35       ` Sébastien Miquel
2022-04-30  8:41         ` Ihor Radchenko
2022-05-30 19:51       ` Sébastien Miquel
2022-05-31  5:14         ` Ihor Radchenko
2022-05-31  6:48           ` Sébastien Miquel
2022-07-16  8:57             ` [FR] Make :var foo=name-of-src-block assign the source block code instead of currently assigned result of evaluation (was: [PATCH] Add :noweb-prefix and :noweb-trans babel header arguments) Ihor Radchenko
2022-07-16 10:17               ` Greg Minshall
2022-07-16 10:45                 ` Ihor Radchenko
2022-07-16 14:31                   ` Greg Minshall
2022-07-17 17:39                   ` Sébastien Miquel
2022-07-23  4:52                     ` Ihor Radchenko
2022-08-29 17:39                       ` [PATCH] " Sébastien Miquel
2022-08-31  4:04                         ` Ihor Radchenko
2022-07-21 11:13             ` [PATCH] org-babel: Do not echo output of resolved noweb references Ihor Radchenko
2022-07-21 13:41               ` Sébastien Miquel
2022-08-22 12:01               ` Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=875ymt8goc.fsf@localhost \
    --to=yantar92@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=sebastien.miquel@posteo.eu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).