From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: bug#26467: 25.2; [Org mode] Call dot babel from elisp generate invalid image Date: Sun, 15 Apr 2018 09:59:49 +0200 Message-ID: <87fu3wlx1m.fsf@nicolasgoaziou.fr> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:42157) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f7cZz-0005hL-8x for emacs-orgmode@gnu.org; Sun, 15 Apr 2018 04:00:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f7cZu-0006eE-DA for emacs-orgmode@gnu.org; Sun, 15 Apr 2018 04:00:07 -0400 Received: from debbugs.gnu.org ([208.118.235.43]:45108) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f7cZu-0006eA-9t for emacs-orgmode@gnu.org; Sun, 15 Apr 2018 04:00:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1f7cZu-0002d2-0g for emacs-orgmode@gnu.org; Sun, 15 Apr 2018 04:00:02 -0400 Sender: "Debbugs-submit" Resent-Message-ID: In-Reply-To: (wang jinjian's message of "Wed, 12 Apr 2017 12:22:07 -0500") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: wang jinjian Cc: 26467@debbugs.gnu.org Hello, wang jinjian 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