emacs-orgmode
[Top][All Lists]
Advanced

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

babel comma escape with :wrap


From: Matt Huszagh
Subject: babel comma escape with :wrap
Date: Fri, 07 Feb 2020 23:42:25 -0800

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



reply via email to

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