- Place the tla-mode.el in the load-path for emacs. Reasonable places may be:
- /usr/share/emacs/site-lisp (usually in the load-path)
- .emacs.d (if it is in the load-path).
- Add to emacs initialization.
-
Simple method in .emacs or .emacs.d/init.el
(require 'tla-mode)
-
With use-package
(use-package tla-mode :mode "\.tla$")
-
tla-mode for emacs provides a major mode for TLA+
Syntax for TLA+ is highlighted. PlusCal syntax is not highlighted.
Keywords can be typed lower case. They are recognized and converted to upper-case automatically.
Code can be indented when hitting the Tab key. Here are cases where this functionality works.
- Hitting tab at the beginning of a line cycles the indentation
through the *\\ and
- symbols found on the previous line.
- Hitting tab after typing a word at the beginning of a line moves cursor below the last ==.
- Hitting tab after THEN or ELSE, indent the line to the last IF or ELSE.
tla-mode supports pretty symbols in conjunction with the prettify-symbols-mode.
- tla-mode is smart enough to check if a symbol rendering is available by the font in use and it only prettifies symbols for which a rendering is available.
- When symbols are used, tla-mode adds extra spaces to symbols to ensure that they have the same width as the character sequence they replace.
Note the following:
- TLA+ is indentation sensitive. So it is useful to use a mono-spaced font.
- Monospaced coding fonts have only a small number of the symbols that TLA+ actually supports.
- It is possible to use a fallback font. i.e. a fallback font is used for a symbol if the primary font does not have a rendering for the symbol.
- However, even if a fallback font is used, the width of characters with that font will be different from the primary font causing inconsistent spacing.
To make this work correctly, do the following:
-
Find a fallback font that supports symbols and has the same width as the primary font. Luckily, a good soul has a solution for this. https://github.com/cpitclaudel/monospacifier has a tool to adjust a variable width font to match the width of a reference font. The same site also has ready to download symbol fonts that are already fixed up to match some commonly used coding fonts.
-
Symbola is a font with good symbol support. To add it as a fallback font, do something like the following.
(dolist (ft (fontset-list)) (set-fontset-font ft 'unicode (font-spec :name "Consolas")) (set-fontset-font ft 'unicode (font-spec :name "Symbola monospacified for Consolas") nil 'append))
-
In tla-mode, enable prettify-symbols-mode (M-x prettify-symbols-mode). To do this always, add a hook
(add-hook 'tla-mode 'prettify-symbols-mode)
When opening an empty .tla file, the Module header and footer is automatically added. This can be prevented by setting tla-template-by-default to nil.