plantuml-mode/README.md

104 lines
4.0 KiB
Markdown
Raw Normal View History

2015-09-22 11:36:33 +02:00
[![MELPA](http://melpa.org/packages/puml-mode-badge.svg)](http://melpa.org/#/puml-mode) [![MELPA Stable](http://stable.melpa.org/packages/puml-mode-badge.svg)](http://stable.melpa.org/#/puml-mode)
2015-09-21 18:00:29 +02:00
2016-05-07 07:50:43 +02:00
# PlantUML mode for Emacs
2012-06-11 13:31:49 +02:00
2015-09-21 17:45:42 +02:00
<img src="https://raw.githubusercontent.com/skuro/puml-mode/master/banner.png"
alt="puml-mode in action" title="Behold the beauty of text-based UML diagrams!" />
2015-09-21 17:55:06 +02:00
> “Pummel me all you want," I say. "Pummel me to death, in fact. My answers will not change."
> The Invierno step back, frowning. "You must love her very much," he says, not unkindly.”
>
2015-09-21 17:55:06 +02:00
> from [The Bitter Kingdom - Fire and Thorns #3](https://www.goodreads.com/book/show/11431896-the-bitter-kingdom)
2012-06-11 13:31:49 +02:00
2015-09-21 17:55:06 +02:00
2015-12-07 16:56:20 +01:00
A [PlantUML](http://plantuml.sourceforge.net/) major mode for Emacs.
2012-06-11 13:31:49 +02:00
2016-05-07 07:50:43 +02:00
# Installation
2015-07-13 23:09:47 +02:00
Make sure you have [MELPA](http://melpa.org/) enabled in your ``emacs.d``. Then, you can just
M-x package-install<RET>
puml-mode<RET>
Also, to enable preview you need to tell `puml-mode` where to locate the PlantUML JAR file. By default it will look for it in `~/plantuml.jar`, but you can specify any location with:
M-x customize-variable<RET>
puml-plantuml-jar-path<RET>
2015-07-13 23:09:47 +02:00
2016-05-07 07:50:43 +02:00
# Features
2015-09-21 17:28:46 +02:00
- Syntax highlight
- Autocompletion
- Preview
2016-05-07 07:50:43 +02:00
# Enable the major mode
2015-09-21 17:28:46 +02:00
You can automatically enable `puml-mode` for files with extension `.puml` or `plantuml` by adding the following to your `.emacsrc`:
;; Enable puml-mode for PlantUML files
(add-to-list 'auto-mode-alist '("\\.puml\\'" . puml-mode))
(add-to-list 'auto-mode-alist '("\\.plantuml\\'" . puml-mode))
2015-09-21 17:28:46 +02:00
Of course, you can always enable manually the major mode by typing `M-x puml-mode` once in the desired PlantUML file buffer.
2016-05-07 07:50:43 +02:00
# Usage
2015-07-13 23:09:47 +02:00
2015-09-21 17:28:46 +02:00
You can either tell `puml-mode` to autocomplete the word before the cursor by typing `M-x puml-complete-symbol`. This will open a popup with all the available completions as found in the list of keywords given by running PlantUML with the `-language` flag.
To render the PlantUML diagram within Emacs, you can also hit `M-x puml-preview`. This will run PlantUML and display the result in the `*PUML-Preview*` buffer. The format used to render the diagram is automagically chosen from what's supported by your Emacs. It will be one of the following, in order of preference:
- SVG
- PNG
2015-09-21 17:28:46 +02:00
- Unicode ASCII art
2016-05-07 07:50:43 +02:00
## Default key bindings
2015-09-21 17:28:46 +02:00
The following shortcuts are enabled by default:
C-c C-c puml-preview: renders a PlantUML diagram from the current buffer in the best supported format
2016-03-24 22:34:50 +01:00
C-u C-c C-c puml-preview in other window
2016-03-24 22:34:50 +01:00
C-u C-u C-c C-c puml-preview in other frame
2015-07-13 23:09:47 +02:00
2016-05-07 07:50:43 +02:00
## Integration with `org-mode`
You can use `puml-mode` to edit PlantUML source snippets within an [`org-mode`](http://orgmode.org/) document. To do so, you need to first register it with the `plantuml` language:
```
(add-to-list
'org-src-lang-modes '("plantuml" . puml))
```
Then you can edit a `plantuml` code block with `puml-mode` by hitting `C-'` while inside of the code block itself:
```elisp
#+BEGIN_SRC plantuml
<hit C-' here to open a puml-mode buffer>
#+END_SRC
```
When in the `puml-mode` buffer you can then hit again `C-'` to return to the original `org-mode` document.
# Troubleshooting
2015-12-07 16:56:20 +01:00
As of `v0.6.2` the following commands have been added to help resolving problems:
```
puml-enable-debug
puml-disable-debug
```
With debug enabled, the actual command used to invoke PlantUML is printed into a buffer called `*PUML Messages*`. You can inspect that buffer to make sure that PlantUML is properly set up, or use it to supply extra information when opening [issues](https://github.com/skuro/puml-mode/issues).
2016-05-07 07:50:43 +02:00
# Credits
2015-09-21 17:55:06 +02:00
This project stemmed from the great work of [Zhang Weize](http://zhangweize.wordpress.com/2010/09/20/update-plantuml-mode/),
and the current code still borrows a lot from it.
Thanks to [Pavel G. Koukoushkin](https://github.com/svargellin) for implementing the preview functionality.
2016-05-07 07:50:43 +02:00
# License
2012-06-11 13:31:49 +02:00
Released under the terms of [GPLv2](http://www.gnu.org/licenses/gpl-2.0.html). See [LICENSE.txt](https://github.com/skuro/plantuml-mode/blob/master/LICENSE.txt).