Permalink
Browse files

Add alpha-level Clojure support. Needs work on special forms, literal…

…s (e.g. regexes, characters, etc).
  • Loading branch information...
kingcons committed Aug 29, 2012
1 parent dd6783a commit 60803117448aa34118f42a10c92a1e3aa0d1a348
Showing with 27 additions and 0 deletions.
  1. +1 −0 README.md
  2. +26 −0 coloring-types.lisp
View
@@ -3,6 +3,7 @@ colorize is a lisp library for syntax highlighting supporting the following lang
* Common Lisp, ```:common-lisp```
* Emacs Lisp, ```:elisp```
* Scheme, ```:scheme```
+* Clojure, ```:clojure``` *alpha*
* C, ```:c```
* C++, ```:c++```
* Java, ```:java```
View
@@ -203,6 +203,32 @@
result (call-parent-formatter))
(call-parent-formatter)))))))
+(define-coloring-type :clojure "Clojure"
+ :parent :lisp
+ :transitions
+ (((:normal :in-list)
+ ((scan "...")
+ (set-mode :symbol
+ :until (scan-any *non-constituent*)
+ :advancing nil))
+ ((scan #\[)
+ (set-mode :in-list
+ :until (scan #\])))
+ ((scan #\{)
+ (set-mode :in-list
+ :until (scan #\})))))
+ :formatters
+ (((:in-list)
+ (lambda (type s)
+ (declare (ignore type s))
+ (let ((*open-parens* (append '(#\{ #\[) *open-parens*))
+ (*close-parens* (append '(#\} #\]) *close-parens*)))
+ (call-parent-formatter))))
+ ((:symbol :escaped-symbol)
+ (lambda (type s)
+ (declare (ignore type))
+ (call-parent-formatter)))))
+
(define-coloring-type :elisp "Emacs Lisp"
:parent :lisp
:formatters

0 comments on commit 6080311

Please sign in to comment.