Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/codyreichert/shakespeare-mode

An emacs major mode for editing hamlet, lucius, and julius files
https://github.com/codyreichert/shakespeare-mode

emacs emacs-lisp haskell melpa yesod

Last synced: about 2 months ago
JSON representation

An emacs major mode for editing hamlet, lucius, and julius files

Awesome Lists containing this project

README

        

#+AUTHOR: Cody Reichert
#+EMAIL: [email protected]
#+TITLE: shakespeare-mode.el [[http://melpa.org/#/shakespeare-mode][file:http://melpa.org/packages/shakespeare-mode-badge.svg]] [[http://stable.melpa.org/#/shakespeare-mode][file: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).

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

** Installation
You can install this package from the MELPA repository:

#+BEGIN_SRC bash
M-x package-install RET shakespeare-mode RET
#+END_SRC

*Note: shakespeare-mode is also available via [[http://stable.melpa.org/#/shakespeare-mode][melpa-stable]] .*

Alternatively, clone this repo and add the directory to your emacs load path by adding the following
lines to your .emacs:

#+BEGIN_SRC elisp
(add-to-list 'load-path "/path/to/this/clone")
(require 'shakespeare-mode)
#+END_SRC

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.

#+BEGIN_SRC elisp
shakespeare-hamlet-mode
shakespeare-julius-mode
shakespeare-lucius-mode
#+END_SRC

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:

#+BEGIN_SRC elisp
#{...}
@{...}
^{...}
@?{...}
_{...}
#+END_SRC

*** 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 (=

=)
- optional quotes around attribute values (==)
- 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 [[http://www.yesodweb.com/book/shakespearean-templates#shakespearean-templates_attributes][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
[[https://github.com/purcell/less-css-mode][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'.

[[https://github.com/lightquake/hamlet-mode][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/