From: Nicolas Goaziou <mail@nicolasgoaziou.fr>
To: wang jinjian <wjj1928@gmail.com>
Cc: 26467@debbugs.gnu.org
Subject: bug#26467: 25.2; [Org mode] Call dot babel from elisp generate invalid image
Date: Sun, 15 Apr 2018 09:59:49 +0200 [thread overview]
Message-ID: <87fu3wlx1m.fsf@nicolasgoaziou.fr> (raw)
In-Reply-To: <CAG8dOtnen=BG8c3u8ouQTXcEy=oqFUHyHRNtA81rCFxun6vfaQ@mail.gmail.com> (wang jinjian's message of "Wed, 12 Apr 2017 12:22:07 -0500")
Hello,
wang jinjian <wjj1928@gmail.com> writes:
> Use case is call dot babel from elisp code block. refer to
> http://orgmode.org/worg/org-tutorials/org-dot-diagrams.html
>
> Below is a more minimal example:
>
> #+NAME: nodes
> | From | To | Weight |
>
> |------+----+--------|
> | A | B | 3 |
> | A | C | 2 |
> | B | D | 4 |
> | B | E | 5 |
> | C | F | 10 |
>
> #+BEGIN_SRC elisp :file a.png :var nodes=nodes
> (defun rowfun(x)
> (format "%s -> %s [label=%s];" (nth 0 x) (nth 1 x) (nth 2 x))
> )
> (defun dotgen(nodes)
> (let ((dotbegin "digraph {\nnode [shape=circle]\n")
> (dotend "\n}"))
> (concat dotbegin
> (mapconcat #'rowfun nodes "\n")
> dotend)))
> (setq params (nth 2 (org-babel-get-src-block-info)))
> (org-babel-execute:dot (dotgen nodes) params)
> #+END_SRC
>
> If run this block with C-c C-c, it will generate a image a.png with
> "nil" string in it. so it's a invalid image file.
I can achieve the desired effect with:
#+name: nodes
| From | To | Weight |
|------+----+--------|
| A | B | 3 |
| A | C | 2 |
| B | D | 4 |
| B | E | 5 |
| C | F | 10 |
#+begin_src elisp :file /tmp/a.png :var nodes=nodes :results file
(defun rowfun (x)
(format "%s -> %s [label=%s];" (nth 0 x) (nth 1 x) (nth 2 x)))
(defun dotgen (nodes)
(format "digraph {\nnode [shape=circle]\n%s\n}"
(mapconcat #'rowfun nodes "\n")))
(dotgen nodes)
#+end_src
I don't see why you would need to call `org-babel-execute:dot'.
Does it fix your issue?
Regards,
--
Nicolas Goaziou 0x80A93738
next prev parent reply other threads:[~2018-04-15 8:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CAG8dOtnen=BG8c3u8ouQTXcEy=oqFUHyHRNtA81rCFxun6vfaQ@mail.gmail.com>
2017-04-12 19:14 ` bug#26467: 25.2; [Org mode] Call dot babel from elisp generate invalid image Glenn Morris
2018-04-15 7:59 ` Nicolas Goaziou [this message]
2018-07-07 11:20 ` 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=87fu3wlx1m.fsf@nicolasgoaziou.fr \
--to=mail@nicolasgoaziou.fr \
--cc=26467@debbugs.gnu.org \
--cc=wjj1928@gmail.com \
/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).