|home| |posts| |projects| |cv| |bookmarks| |github|

Plantuml in Emacs

Install PlantUML

On Debian based GNU/Linux distributions you can install it via the package manager:

sudo apt install plantuml

Emacs configuration

Assuming that you use use-package to manage your Emacs config, you can add this code to your emacs config file:

(use-package plantuml-mode)

(org-babel-do-load-languages 'org-babel-load-languages '((plantuml . t)))

(setq org-plantuml-jar-path (expand-file-name "/usr/share/plantuml/plantuml.jar"))

(setq plantuml-default-exec-mode 'executable)

Usage

org-mode

  1. Open a org-mode buffer and enter the following code
#+BEGIN_SRC plantuml :file dead_parrot_sketch.png
title Dead Parrot sketch

Mr.Praline -> Owner: 'Ello, I wish to register a complaint.

Mr.Praline -> Owner: 'Ello, Miss?
Owner --> Mr.Praline: What do you mean "miss"?

Mr.Praline -> Owner: I'm sorry, I have a cold
#+END_SRC
  1. Place your cursor inside the code block and run C-c C-c y, open image named dead_parrot_sketch.png, it should look like this:

plantuml-mode

Create a new file that ends with .plantuml(or run M-x plantuml-mode if the file doesn't end with .plantuml) to enable plantuml-mode and have syntax-highlighting, auto-indentation etc.

Write/update the source code and run C-c C-c to generate a preview of the diagram.