emacs-orgmode
[Top][All Lists]
Advanced

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

[O] How to define file-local preamble for graphviz dot?


From: Vladimir Alexiev
Subject: [O] How to define file-local preamble for graphviz dot?
Date: Fri, 1 Aug 2014 19:28:01 +0300

I have a bunch of dot settings that I want to set globally. I hacked it like 
this:

(setq va/org-dot-preamble "digraph g {
  rankdir=LR nodesep=0.2 ranksep=0.1 arrowsize=0.2
  node [fontname=courier fontsize=10 margin=\"0.02,0.01\" shape=box width=0.1 
height=0.1]
  edge [fontname=courier fontsize=8 labelfontname=courier labelfontsize=8]")

(defadvice org-babel-expand-body:dot (before add-preamble (body params) 
activate)
  "add DOT=va/org-dot-preamble as :var in params, so $dot is replaced with it"
  (setq params (cons (cons ':var (cons 'DOT va/org-dot-preamble))
                     params)))

And then I start dot code blocks with "$dot", which is replaced with the above 
string:

#+begin_src dot :results silent file :file ./img/SymmetricProperty.png
$dot 
x -> y [label="q"]
y -> x [label="q" color=red]
}
#+end_src

I can override a dot param by adding a different value after the common 
inclusion $dot, e.g.:
$dot ranksep=0.7

The problem is
*** how can I make this per-file? 
Neither #+BIND nor emacs "Local Variables:" does the trick.
Bonus if I can do it per-heading :-)

dot can take these settings from the command line, eg
-G "rankdir=LR nodesep=0.2 ranksep=0.1 arrowsize=0.2"
-N "fontname=courier fontsize=10 margin=\"0.02,0.01\" shape=box width=0.1 
height=0.1"
-E "fontname=courier fontsize=8 labelfontname=courier labelfontsize=8"

So I could try to mess with the :cmdline slot of 
org-babel-default-header-args:dot ... is this evaluated locally?





reply via email to

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