From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Vladimir Alexiev" Subject: Re: How to define file-local preamble for graphviz dot? Date: Tue, 5 Aug 2014 17:30:10 +0300 Message-ID: <23315.361623145$1407249060@news.gmane.org> Reply-To: vladimir.alexiev@ontotext.com Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:46827) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XEfko-0000oO-Hi for emacs-orgmode@gnu.org; Tue, 05 Aug 2014 10:30:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XEfki-00075J-Dk for emacs-orgmode@gnu.org; Tue, 05 Aug 2014 10:30:18 -0400 Received: from mail.ontotext.com ([93.123.21.89]:39575 helo=ontomail.ontotext.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XEfki-000759-5w for emacs-orgmode@gnu.org; Tue, 05 Aug 2014 10:30:12 -0400 Received: from localhost (localhost [127.0.0.1]) by ontomail.ontotext.com (Postfix) with ESMTP id 233D92F1CB for ; Tue, 5 Aug 2014 17:30:11 +0300 (EEST) Received: from ontomail.ontotext.com ([127.0.0.1]) by localhost (localhost [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id df4gjL7oEM+2 for ; Tue, 5 Aug 2014 17:30:10 +0300 (EEST) Received: from vladoa (client-93-123-21-124.ip.daticum.com [93.123.21.124]) by ontomail.ontotext.com (Postfix) with ESMTPSA id C6C982F1C6 for ; Tue, 5 Aug 2014 17:30:10 +0300 (EEST) References: In-Reply-To: Content-Language: en-us 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-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Vladimir Alexiev ontotext.com> writes: > I have a bunch of dot settings that I want to set globally. I hacked it like this: > (defadvice org-babel-expand-body:dot (before add-preamble (body params) activate) A better way to hack it is like that, using the header args :prologue and :epilogue (eval-after-load "ob-dot" ' (progn (add-to-list 'org-babel-default-header-args:dot '(:cache . "yes")) (add-to-list 'org-babel-default-header-args:dot '(:prologue . "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]")) (add-to-list 'org-babel-default-header-args:dot '(:epilogue . "}")))) Unfortunately ob-dot doesn't interpret :prologue and :epilogue, so I adviced it: (defadvice org-babel-expand-body:dot (before prologue-epilogue activate) "Interpret :prologue and :epilogue headers, like org-babel-expand-body:generic" (let ((pro (cdr-safe (assoc :prologue params))) (epi (cdr-safe (assoc :epilogue params)))) (setq body (mapconcat #'identity (append (when pro (list pro)) (list body) (when epi (list epi))) "\n")))) Then in a particular file I can override the :prologue like so: * Local Variables :noexport: Local Variables: eval: (setq-local org-babel-default-header-args:dot (cons '(:prologue . "digraph g { rankdir=LR nodesep=0.2 ranksep=0.3 arrowsize=0.1 node [fontname=courier fontsize=8 margin=\"0.02,0.01\" shape=circle width=0.25 height=0.25 label=\"\"] edge [fontname=courier fontsize=8 labelfontname=courier labelfontsize=8]") (cl-remove :prologue org-babel-default-header-args:dot :key 'car :test 'eq))) End: This works, although it asks for confirmation every time the file is loaded. Trying to do it with a code block: #+BEGIN_SRC emacs-lisp :results silent :exports none #+END_SRC didn't work because that code is not executed automatically on export.