Home > Emacs, Python > Cheetah Mode for Emacs

Cheetah Mode for Emacs

July 31st, 2006

Here is a simple html derived mode for Cheetah templates files. The font-locking regexp can be improved thought but that’s a start.

(define-derived-mode cheetah-mode html-mode "Cheetah"
  (make-face 'cheetah-variable-face)
  (font-lock-add-keywords
   nil
   '(
     ("\\(#\\(from\\|else\\|include\\|set\\|import\\|for\\|if\\|end\\)+\\)\\>" 1 font-lock-type-face)
     ("\\(#\\(from\\|for\\|end\\)\\).*\\<\\(for\\|import\\|if\\|in\\)\\>" 3 font-lock-type-face)
     ("\\(\\$\\(?:\\sw\\|}\\|{\\|\\s_\\)+\\)" 1 font-lock-variable-name-face))
   )
  (font-lock-mode 1)
  )
(setq auto-mode-alist (cons '( "\\.tmpl\\'" . cheetah-mode ) auto-mode-alist ))

Emacs, Python

  1. January 7th, 2008 at 10:05 | #1

    Here is an improved version with more keywords:
    http://braydon.com/?p=436

  1. No trackbacks yet.