emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Matt Huszagh <huszaghmatt@gmail.com>
To: "emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>
Subject: babel comma escape with :wrap
Date: Fri, 07 Feb 2020 23:42:25 -0800	[thread overview]
Message-ID: <87imkhikym.fsf@gmail.com> (raw)

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	other threads:[~2020-02-08  7:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-08  7:42 Matt Huszagh [this message]
2020-02-08  8:18 ` babel comma escape with :wrap Nicolas Goaziou

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=87imkhikym.fsf@gmail.com \
    --to=huszaghmatt@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /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).