* babel comma escape with :wrap
@ 2020-02-08 7:42 Matt Huszagh
2020-02-08 8:18 ` Nicolas Goaziou
0 siblings, 1 reply; 2+ messages in thread
From: Matt Huszagh @ 2020-02-08 7:42 UTC (permalink / raw)
To: emacs-orgmode@gnu.org
There appears to be no way to disable the comma escape when using :wrap
for a babel source block.
I'm essentially trying to replicate this example from the manual
#+NAME: attr_wrap
#+BEGIN_SRC sh :var data="" :var width="\\textwidth" :results output
echo "#+ATTR_LATEX: :width $width"
echo "$data"
#+END_SRC
#+HEADER: :file /tmp/it.png
#+BEGIN_SRC dot :post attr_wrap(width="5cm", data=*this*) :results drawer
digraph{
a -> b;
b -> c;
c -> a;
}
#+end_src
#+RESULTS:
:RESULTS:
#+ATTR_LATEX :width 5cm
[[file:/tmp/it.png]]
:END:
But, my result type is a link not a drawer (which are mutually
exclusive). So, to get the same wrapping effect, I need to use the :wrap
argument. However, the comma escape negates attr_wrap's effect with this
code
(let ((wrap
(lambda (start finish &optional no-escape no-newlines
inline-start inline-finish)
(when inline
(setq start inline-start)
(setq finish inline-finish)
(setq no-newlines t))
(let ((before-finish (copy-marker end)))
(goto-char end)
(insert (concat finish (unless no-newlines "\n")))
(goto-char beg)
(insert (concat start (unless no-newlines "\n")))
(unless no-escape
(org-escape-code-in-region
(min (point) before-finish) before-finish))
(goto-char end))))
[...]
But, since this file uses lexical binding (as it should) there appears
to be no way to set no-escape. I searched through the changelog a bit
and that seems to be a relic from an old version. At the very least,
that no-escape conditional should be made unconditional. However, I do
think there should be a way to avoid the comma escape, but I'm not sure
of the best way to do it. I'm more than happy to write the code, but I'm
curious what people think would be the best way to do it.
Maybe :wrap could take a special keyword argument (e.g. no-escape) that
would stop the effect. Thoughts?
Best,
Matt
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: babel comma escape with :wrap
2020-02-08 7:42 babel comma escape with :wrap Matt Huszagh
@ 2020-02-08 8:18 ` Nicolas Goaziou
0 siblings, 0 replies; 2+ messages in thread
From: Nicolas Goaziou @ 2020-02-08 8:18 UTC (permalink / raw)
To: Matt Huszagh; +Cc: emacs-orgmode@gnu.org
Hello,
Matt Huszagh <huszaghmatt@gmail.com> writes:
> There appears to be no way to disable the comma escape when using :wrap
> for a babel source block.
>
> I'm essentially trying to replicate this example from the manual
>
> #+NAME: attr_wrap
> #+BEGIN_SRC sh :var data="" :var width="\\textwidth" :results output
>
> echo "#+ATTR_LATEX: :width $width"
> echo "$data"
> #+END_SRC
>
> #+HEADER: :file /tmp/it.png
> #+BEGIN_SRC dot :post attr_wrap(width="5cm", data=*this*) :results drawer
>
> digraph{
> a -> b;
> b -> c;
> c -> a;
> }
> #+end_src
>
> #+RESULTS:
> :RESULTS:
> #+ATTR_LATEX :width 5cm
> [[file:/tmp/it.png]]
> :END:
>
> But, my result type is a link not a drawer (which are mutually
> exclusive). So, to get the same wrapping effect, I need to use the :wrap
> argument. However, the comma escape negates attr_wrap's effect with this
> code
Could you clarify what you obtain, and what is wrong with it?
Thank you!
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-02-08 8:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-02-08 7:42 babel comma escape with :wrap Matt Huszagh
2020-02-08 8:18 ` Nicolas Goaziou
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.