A major mode that provides syntax highlighting and indentation for editing Shakespearean templates (hamlet, lucius, julius).
You can install this package from the MELPA repository:
M-x package-install RET shakespeare-mode RET
Note: shakespeare-mode is also available via melpa-stable .
Alternatively, clone this repo and add the directory to your emacs load path by adding the following lines to your .emacs:
(add-to-list 'load-path "/path/to/this/clone")
(require 'shakespeare-mode)
And that’s it. Open up a hamlet, lucius, or julius file to make sure it worked.
After installation, you’ll have three major modes. .hamlet
, .lucius
, and
.julius
files should inherit their mode automatically.
shakespeare-hamlet-mode
shakespeare-julius-mode
shakespeare-lucius-mode
They each have mode-maps and hooks you use to add functions and key bindings to them individually.
Alternatively, a minor mode is also loaded with mode-maps and mode-hooks
that runs in all shakespeare buffers. To use this, just hook into
shakespeare-mode
.
Currently, shakespeare-mode supports basic syntax highlighting and indentation for hamlet, lucius, and julius. Cassius files are not yet supported.
All of the modes support syntax highlighting for variable interpolation:
#{...}
@{...}
^{...}
@?{...}
_{...}
shakespeare-hamlet-mode has full support for most hamlet features (submit an issue if any are missing!):
- control flow statements (
$if
,$forall
,$maybe
, etc) - shorthand class and id attributes (
<p .some-class #some-id>
) - optional quotes around attribute values (
<input type=text>
) - no need to explicitly tag
div
elements. (<.mydiv>
)
shakespeare-lucius-mode supports a lot of the same things as shakespeare-hamlet-mode
- url and variable interpolation
- indentation for nested css blocks
- variable declaration
- lucius mixins
shakespeare-julius-mode is the most basic of the modes, but supports Javascript syntax highlighting indentation and the variable interpolation mentioned above.
- Support for setting option attributes with colons, as dicussed here.
- Support far Cassius (shakespeare-cassius-mode)
- Integration with html2hamlet for quick formatting of buffers and regions (eg, copy in html and quickly reformat to hamlet.)
less-css-mode I was originally using less-css-mode for editing lucius files, so I used parts of this mode’s modified syntax-table to compose lucius’.
hamlet mode I was able to use parts of the regexp’s from this repo for syntax highlighting, and parts of the syntax-table. There’s been some reformatting and minor restructure but this was a big help.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/