]> code.delx.au - gnu-emacs-elpa/commitdiff
Document new dispatch API.
authorJackson Ray Hamilton <jackson@jacksonrayhamilton.com>
Sun, 1 Feb 2015 07:55:44 +0000 (23:55 -0800)
committerJackson Ray Hamilton <jackson@jacksonrayhamilton.com>
Sun, 1 Feb 2015 07:55:44 +0000 (23:55 -0800)
README.md

index 14f4f1aa7413966d69f5557a0194eebbbf581c21..af1be13fd805ad79972dd8dfee1244bdfc79422f 100644 (file)
--- a/README.md
+++ b/README.md
@@ -91,8 +91,9 @@ theme used in the screenshot above).
 
 ## Extending
 
-To add support for a new language, write a "scopifier" for it, and add an entry
-to `context-coloring-dispatch-plist`. Then the plugin should handle the rest.
+To add support for a new language, write a "scopifier" for it, and define a new
+coloring dispatch strategy with `context-coloring-define-dispatch`. Then the
+plugin should handle the rest.
 
 A "scopifier" is a CLI program that reads a buffer's contents from stdin and
 writes a JSON array of numbers to stdout. Every three numbers in the array
@@ -123,6 +124,24 @@ If there is an abstract syntax tree generator for your language, you can walk
 the syntax tree, find variables and scopes, and build their positions and levels
 into an array like the one above.
 
+For example, a Ruby scopifier might be defined and implemented like this:
+
+```lisp
+(context-coloring-define-dispatch 'ruby
+  :modes '(ruby-mode)
+  :executable "ruby"
+  :command "/home/username/scopifier")
+```
+
+```ruby
+#!/usr/bin/env ruby
+def scopifier(code)
+    # Parse code.
+    # Return an array.
+end
+print scopifier ARGF.read
+```
+
 [linter]: http://jshint.com/about/
 [flycheck]: http://www.flycheck.org/
 [zenburn]: http://github.com/bbatsov/zenburn-emacs