emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* problem with babel and dot
@ 2016-02-12 16:15 Eric S Fraga
  2016-02-12 18:28 ` Eric S Fraga
  0 siblings, 1 reply; 3+ messages in thread
From: Eric S Fraga @ 2016-02-12 16:15 UTC (permalink / raw)
  To: emacs-orgmode

Hello,

I have the following emacs lisp code to build up a dot input for a
dependency graph:

#+begin_src org
  ,#+name: graph-from-tables
  ,#+header: :var options="" :var nodes='() graph='()
  ,#+BEGIN_SRC emacs-lisp 
    (org-babel-execute:dot
     (concat
          "digraph {\n"
          options "\n"   ;; "//rankdir=LR;\n" ;; remove comment characters '//' for horizontal layout; add for vertical layout
          (mapconcat
           (lambda (x)
             (format "%s [label=\"%s\" shape=%s style=\"filled\" fillcolor=\"%s\"]"
                             (car x)
                             (nth 1 x)
                             (if (string= "" (nth 2 x)) "box" (nth 2 x))
                             (if (string= "" (nth 3 x)) "none" (nth 3 x))
                             )) nodes "\n")
          "\n"
          (mapconcat
           (lambda (x)
             (format "%s -> %s [taillabel=\"%s\"]"
                             (car x) (nth 1 x) (nth 2 x))) graph "\n")
          "}\n") params)
  ,#+END_SRC
#+end_src

This used to work but was last used probably a year ago or more.

I invoke this function elsewhere in the document with a call like this:

#+begin_src org
  ,#+call: graph-from-tables[:file dependency-graph.pdf](options="rankdir=LR;",nodes=subtasks-table[2:-1],graph=dependency-table[2:-1]) :results file :exports results
#+end_src

Two tables are used to describe the dependency graph and the information
passed to the function above works just fine.  The input file for dot
also looks perfect (and if I run dot on it, I get the graph I
want).  However, the result of the call here is a file,
dependency-graph.pdf, which has 3 bytes: "nil".

I have no idea how to get this working again.  ob-dot.el provides no
clues to me unfortunately.

Any pointers please?

Many thanks,
eric

-- 
: Eric S Fraga (0xFFFCF67D), Emacs 25.0.90.1, Org release_8.3.3-565-g4f499f

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: problem with babel and dot
  2016-02-12 16:15 problem with babel and dot Eric S Fraga
@ 2016-02-12 18:28 ` Eric S Fraga
  2016-02-13 11:00   ` Eric S Fraga
  0 siblings, 1 reply; 3+ messages in thread
From: Eric S Fraga @ 2016-02-12 18:28 UTC (permalink / raw)
  To: emacs-orgmode

I've had a suggestion to use ":wrap src dot" for my elisp code, to avoid
using internal API calls.  This is a good suggestion but I cannot figure
out how to actually accomplish what I want.

Basically, I want to #+call: a src block which takes my tables as
arguments, uses my elisp code to generate a suitable DOT input and then
invokes DOT on that input to generate an image file specified on the
call invocation:

  tables -> emacs lisp -> dot -> pdf file

I think that a creative use of :post may do it but I cannot get my head
around how to invoke the various bits and/or pass the data I need.

Thanks,
eric

-- 
: Eric S Fraga (0xFFFCF67D), Emacs 25.0.90.1, Org release_8.3.3-565-g4f499f

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: problem with babel and dot
  2016-02-12 18:28 ` Eric S Fraga
@ 2016-02-13 11:00   ` Eric S Fraga
  0 siblings, 0 replies; 3+ messages in thread
From: Eric S Fraga @ 2016-02-13 11:00 UTC (permalink / raw)
  To: emacs-orgmode

Okay, I have figured this out and here is the solution in case anybody
else wants to do something like this:

1. create a very simple dot src block:

   #+begin_src org
     ,#+name: generate-graph
     ,#+begin_src dot :var graph="digraph {}" :file graph.pdf
       $graph
     ,#+end_src
   #+end_src

2. call the original tables -> graph block with a :post command to
   invoke this new block:

   #+begin_src org
     ,#+call: graph-from-tables(options="rankdir=LR;",nodes=subtasks-table[2:-1],graph=dependency-table[2:-1]) :exports results :results file :post generate-graph[:results file :exports results :file dependency-graph.pdf](graph=*this*)
   #+end_src

This works like a charm.  There are probably superfluous settings but
this over-specified combination does what I want!

Sorry for all the noise.  As always, power comes with complexity and
babel is definitely powerful.  If org is the killer app for emacs, then
babel is the killer app for org!


thanks,
eric

-- 
: Eric S Fraga (0xFFFCF67D), Emacs 25.0.90.1, Org release_8.3.3-565-g4f499f

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-02-13 11:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-12 16:15 problem with babel and dot Eric S Fraga
2016-02-12 18:28 ` Eric S Fraga
2016-02-13 11:00   ` Eric S Fraga

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).