[slime-devel] Font-lock trickery

Nikodemus Siivola tsiivola at cc.hut.fi
Wed May 5 13:27:51 UTC 2004


Instead of doing something useful I spent the first part of the day
coaxing/cargo-culting emacs to fontify user-definied defoo forms nicely.

In case someone else is was annoyed by the this lack of
angry-fruit-saladness, here goes (eg. add this to lisp-mode-hook):

 ;; Fontification for user-defined defoo macros
 (font-lock-add-keywords
  'lisp-mode
  '(("(\\(def.*?\\)\\>[ 	'(]*\\(setf[ 	]+\\sw+)\\|\\sw+\\)?"
    (1 font-lock-keyword-face)
    (2 (let ((name (match-string 2)))
         (when name
           (cond ((string-match "^\\*" name)
                   font-lock-variable-name-face)
                 ((string-match "^\\+" name)
                   font-lock-constant-name-face)
                 (t
                   font-lock-function-name-face)))))))
  t)

Won't take effect without restarting emacs -- or some other trickery that
I'm not aware of.

Cheers,

 -- Nikodemus




More information about the slime-devel mailing list