Skip to content

Instantly share code, notes, and snippets.

@krisajenkins
Created January 26, 2013 16:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save krisajenkins/4643080 to your computer and use it in GitHub Desktop.
Save krisajenkins/4643080 to your computer and use it in GitHub Desktop.
def*-style syntax highlighting for Clojure in Emacs - Annotated
; Add a function that runs for any Clojure buffer.
(add-hook 'clojure-mode-hook
; It's an anonymous function and it takes no arguments.
'(lambda ()
; It calls the function that adds syntax-highlighting rules.
(font-lock-add-keywords nil
; So many escape codes! But behind those we're just saying:
; Match the '(' character.
; Match and group the string 'defwidget'.
; Match some whitespace. \\s-+
; Match and group some word characters. \\w+
'(("(\\(defwidget\\)\\s-+\\(\\w+\\)"
(1 font-lock-keyword-face) ; The first regexp group is a keyword.
(2 font-lock-function-name-face) ; The second regexp group is a name.
))))) ; Close up the patient.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment