Skip to content

ianxm/emacs-uml

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

56 Commits
 
 
 
 
 
 
 
 

Repository files navigation

https://melpa.org/packages/uml-mode-badge.svg https://img.shields.io/badge/license-GPL_3-green.svg

uml-mode

overview

emacs is a text editor. an extensible one. it is mainly used for coding, but it can also do anything else. uml is a modeling language for creating diagrams of software design.

uml-mode.el is a minor mode for emacs that makes it easier to build ascii sequence diagrams in emacs. my goal is for it to do for sequence diagrams what orgtbl-mode does for tables.

ascii uml diagrams are quick and easy to make and can be emailed without attachment or embedded in code comments.

example

uml-mode.el can be used to make ascii uml sequence diagrams like this:

person1                    person2     kitchen
   |                          |           |
   |   make me a sandwich     |           |
   |------------------------->|           |
   |                          |           |
   |         no way           |           |
   |< - - - - - - - - - - - - |           |
   |                          |           |
   | sudo make me a sandwich  |           |
   |------------------------->|           |
   |                          |           |
   |                          |    go     |
   |                          |---------->|
   |                          |           |
   |                          |           | --.
   |                          |           |<--' make it
   |                          |           |
   |                          |< - - - - -|
   |                          |           |
   |        sandwich          |           |
   |< - - - - - - - - - - - - |           |
   |                          |           |

features

  • only supports sequence diagrams
  • provides key bindings for more easily moving around sequence diagrams, and aligning and redrawing them
  • diagrams can be embedded in source code comments

installation

melpa

  1. run M-x package-install RET uml-mode

manual install

  1. download uml-mode.el
  2. run M-x package-install-file RET
  3. choose uml-mode.el

tutorial

timelines

if you move the point over a line with some names and hit C-c C-c to redraw it, the list of names will be spread out and centered over timelines.

put the following content in a buffer, enabled uml-mode (M-x uml-mode), and hit C-c C-c while the point is on the line.

timeline1 timeline2 timeline3

the above line will be replaced with:

timeline1   timeline2   timeline3
    |           |           |

you can modify the diagram at any point and run redraw again and uml-mode will clean it up.

arrow to neighbor

arrows can be added by putting a single dash next to a timeline (pipe character below a timeline name). this will draw an arrow to the nearest neighbor in that direction.

add a dash next to a timeline, as shown below, and run redraw to create an arrow to its neighbor.

timeline1   timeline2   timeline3
    |-           |           |

becomes

timeline1   timeline2   timeline3
    |           |           |
    |---------->|           |
    |           |           |
arrow to any timeline

an angle bracket near a timeline indicates the other end of the arrow. both the angle bracket and the dash are used to determine which timelines to connect. there can only be one arrow per line.

timeline1     timeline2     timeline3
   |-           |          >|

becomes

timeline1     timeline2     timeline3
   |           |           |
   |---------------------->|
   |           |           |
arrow to the left

create arrows that go to the left by reversing the angle bracket and dash.

timeline1     timeline2     timeline3
   |<           |          -|

becomes

timeline1     timeline2     timeline3
   |           |           |
   |<----------------------|
   |           |           |
dashed arrows

arrows will be dashed if there is a non-consecutive missing dash at any point in the line.

timeline1     timeline2     timeline3
   |- -          |          >|

or

timeline1     timeline2     timeline3
   |- ---------------------->|

becomes

timeline1     timeline2     timeline3
   |           |           |
   | - - - - - - - - - - ->|
   |           |           |
labels

labels can be entered on the line above or the same line as the arrow. there can only be one label per line.

timeline1     timeline2     timeline3
   | call          |          |
   |-           |          |

or

timeline1     timeline2     timeline3
   |- call        |          |

becomes

timeline1     timeline2     timeline3
   |           |           |
   |   call    |           |
   |---------->|           |
   |           |           |
self arrows

self arrows are made by keeping the angle bracket and any dashes under the same timeline.

timeline1     timeline2     timeline3
   |< call         |          |

becomes

timeline1     timeline2     timeline3
   |           |           |
   | --.       |           |
   |<--' call  |           |
   |           |           |
comments

diagrams can be embedded in source code comments.

#
# timeline1 timeline2
#    |-

;;
;; timeline1 timeline2
;;   |-
;;

//
// timeline1 timeline2
//   |-
//

/*
 * timeline1 timeline2
 *   |-
 */

becomes

#  timeline1   timeline2
#      |           |
#      |---------->|
#      |           |

;;   timeline1     timeline2
;;      |           |
;;      |---------->|
;;      |           |
;;

//  timeline1   timeline2
//      |           |
//      |---------->|
//      |           |
//

/*
 *  timeline1   timeline2
 *      |           |
 *      |---------->|
 *      |           |
 */

reference

default keymap
keyaction
C-c C-credraw the diagram at the point
M-fmove forward to the next word or timeline
M-bmove backward to the previous word or timeline
M-leftshift a timeline to the left
M-rightshift a timeline to the right
M-S-leftdelete the timeline at the point
M-S-rightinsert a timeline to the right
syntax rules

timeline names can contain special characters but cannot contain spaces. timeline names can be multiple lines, but be sure to keep the names that are part of the same timeline lined up vertically.

labels must start with a letter or number but can contain any special characters except pipe (|), dash (-), or angle brackets (<>).

comment prefixes can be any length and can contain any special characters, but cannot contain letters or numbers. comment prefixes can contain leading spaces but cannot contain spaces in the middle or at the end.

todo

  • separators
  • swap arrow up or down
  • move cursor up or down by an arrow
  • class diagrams

About

emacs minor mode for editing ascii uml sequence diagrams

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published