emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [Feature request] String escaped noweb expansion
@ 2021-05-02 16:24 Sébastien Miquel
  2021-05-02 17:59 ` Timothy
  0 siblings, 1 reply; 5+ messages in thread
From: Sébastien Miquel @ 2021-05-02 16:24 UTC (permalink / raw)
  To: emacs-orgmode

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



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Feature request] String escaped noweb expansion
  2021-05-02 16:24 [Feature request] String escaped noweb expansion Sébastien Miquel
@ 2021-05-02 17:59 ` Timothy
  2021-05-02 18:16   ` Sébastien Miquel
  2021-05-02 18:34   ` Tom Gillespie
  0 siblings, 2 replies; 5+ messages in thread
From: Timothy @ 2021-05-02 17:59 UTC (permalink / raw)
  To: sebastien.miquel; +Cc: emacs-orgmode


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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Feature request] String escaped noweb expansion
  2021-05-02 17:59 ` Timothy
@ 2021-05-02 18:16   ` Sébastien Miquel
  2021-05-02 18:32     ` Timothy
  2021-05-02 18:34   ` Tom Gillespie
  1 sibling, 1 reply; 5+ messages in thread
From: Sébastien Miquel @ 2021-05-02 18:16 UTC (permalink / raw)
  To: Timothy; +Cc: emacs-orgmode


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



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Feature request] String escaped noweb expansion
  2021-05-02 18:16   ` Sébastien Miquel
@ 2021-05-02 18:32     ` Timothy
  0 siblings, 0 replies; 5+ messages in thread
From: Timothy @ 2021-05-02 18:32 UTC (permalink / raw)
  To: sebastien.miquel; +Cc: emacs-orgmode


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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Feature request] String escaped noweb expansion
  2021-05-02 17:59 ` Timothy
  2021-05-02 18:16   ` Sébastien Miquel
@ 2021-05-02 18:34   ` Tom Gillespie
  1 sibling, 0 replies; 5+ messages in thread
From: Tom Gillespie @ 2021-05-02 18:34 UTC (permalink / raw)
  To: Timothy; +Cc: sebastien.miquel, emacs-orgmode

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-05-02 18:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-05-02 16:24 [Feature request] String escaped noweb expansion Sébastien Miquel
2021-05-02 17:59 ` Timothy
2021-05-02 18:16   ` Sébastien Miquel
2021-05-02 18:32     ` Timothy
2021-05-02 18:34   ` Tom Gillespie

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).