Skip to content

Latest commit

 

History

History
40 lines (37 loc) · 1.49 KB

starter-kit-graphviz.org

File metadata and controls

40 lines (37 loc) · 1.49 KB

Emacs Starter Graphviz

Starter Kit Graphviz

Basic Set up

Auto load graphviz-dot-mode for *.gv.

(setq auto-mode-alist (append '(("\\.gv\\'" . graphviz-dot-mode))
                              auto-mode-alist))

Function to compile

Define my function to compile.

(defun my-graghviz-compile (&optional format)
  "Compile current graphviz file."
  (interactive (list (read-string "my-graphviz-compile :: Enter output format (default is png): ")))
  (save-buffer)
  (let (output-format graphviz-file output-file)
    (if (not (equal 0 (length format)))
        (setq output-format format)
      (setq output-format "png"))
    (setq graphviz-file (buffer-name))
    (setq output-file (concat (file-name-base graphviz-file) "." output-format))
    (shell-command (format "dot -T%s %s -o %s" output-format graphviz-file output-file))))

Key bindings

  • Graphviz-dot-mode bind “C-c c” to compile, which contradicts with org

capture. So it is unbinded in favour of org mode. And I don’t like the other key bindings also.

  • Emacs key binding for compiling graphviz file for this mode.
(eval-after-load "graphviz-dot-mode"
  `(progn
     (define-key graphviz-dot-mode-map (kbd "C-c c") nil)
     (define-key graphviz-dot-mode-map (kbd "C-c p") nil)
     (define-key graphviz-dot-mode-map (kbd "C-c v") nil)
     (define-key graphviz-dot-mode-map (kbd "C-c C-c") 'my-graghviz-compile)))