An emacs major mode for editing hamlet, lucius, and julius files
Emacs Lisp
Switch branches/tags
Nothing to show
Clone or download
CodyReichert Fix error during indentation of first non-empty line
Fixes #13

The package was throwing an error (or hanging, rather) when starting a
new file with a blank line at the very begining. To reproduce:

- Create a new hamlet file and open it
- Hit "o" (newline-and-indent)
- Emacs hangs until C-g is pressed

The error is caused by trying to count the indentation level on a line
that doesn't have any characters on it. There's a two part fix here,
mostly for posterity:

1. Prematurely check if we're on the first non-empty line and use
'noindent.
2. When calcuating indentation of previous lines, make sure that a
character exists on the line before calculating the number of empty
spaces.

There still seems to be a couple of corner cases around auto-indenting
and just various setups, but this should fix the immediate issue.
Latest commit c442eee Jul 4, 2018

README.org

shakespeare-mode.el http://melpa.org/packages/shakespeare-mode-badge.svg http://stable.melpa.org/packages/shakespeare-mode-badge.svg

A major mode that provides syntax highlighting and indentation for editing Shakespearean templates (hamlet, lucius, julius).

https://cloud.githubusercontent.com/assets/7034627/5676535/fced8f2a-979c-11e4-8619-683bba400707.jpg

Installation

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.

Usage

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.

Features

Currently, shakespeare-mode supports basic syntax highlighting and indentation for hamlet, lucius, and julius. Cassius files are not yet supported.

Variable Interpolation

All of the modes support syntax highlighting for variable interpolation:

 #{...}
 @{...}
 ^{...}
@?{...}
 _{...}

Hamlet Mode

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>)

Lucius Mode

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

Julius Mode

shakespeare-julius-mode is the most basic of the modes, but supports Javascript syntax highlighting indentation and the variable interpolation mentioned above.

Todo (in order of priority)

  • 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.)

Thanks

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.

License

This software is licensed under the GNU General Publice License Version 3.0

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/