Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 106 lines (89 sloc) 3.02 KB
;;; tt-mode.el --- Emacs major mode for editing Template Toolkit files.
;; Copyright (c) 2002 Dave Cross, all rights reserved.
;; This file may be distributed under the same terms as GNU Emacs.
;; $Id$
;; This file adds simple font highlighting of TT directives when you are
;; editing Template Toolkit files.
;; I usually give these files an extension of .tt and in order to automatically
;; invoke this mode for these files, I have the following in my .emacs file.
;; (setq load-path
;; (cons "/home/dave/xemacs" load-path))
;; (autoload 'tt-mode "tt-mode")
;; (setq auto-mode-alist
;; (append '(("\\.tt$" . tt-mode)) auto-mode-alist ))
;; Something similar may well work for you.
;; Author: Dave Cross <>
;; Some enhancements by Steve Sanbeg
(require 'font-lock)
(defvar tt-mode-hook nil
"List of functions to call when entering TT mode")
(defvar tt-keywords
(concat "\\b\\(?:"
(regexp-opt (list "GET" "CALL" "SET" "DEFAULT" "INSERT" "INCLUDE"
(defvar tt-font-lock-keywords
;; Fontify [& ... &] expressions
(1 font-lock-builtin-face t)
(2 font-lock-variable-name-face t)
(4 font-lock-builtin-face t))
'("\\[% *\\([a-z_0-9]*\\) *%\\]"
(1 font-lock-constant-face t))
;;line comment - doesn't find multiple comments in a block yet.
(2 font-lock-comment-face t))
;;block comment
(1 font-lock-comment-face t))
;; Look for keywords within those expressions
(list (concat
3 font-lock-keyword-face t)
"Expressions to font-lock in tt-mode.")
;;single quote strings should highlight the same as double quote
(defvar tt-mode-syntax-table
(let ((table (make-syntax-table)))
(modify-syntax-entry ?' "\"" table)
(modify-syntax-entry ?% "." table)
(defun tt-mode ()
"Major mode for editing Template Toolkit files"
(setq major-mode 'tt-mode
mode-name "TT")
(set-syntax-table tt-mode-syntax-table)
(if (string-match "Xemacs" emacs-version)
(make-local-variable 'font-lock-keywords)
(setq font-lock-keywords tt-font-lock-keywords))
;; Emacs
(make-local-variable 'font-lock-defaults)
(setq font-lock-defaults '(tt-font-lock-keywords nil t))
(font-lock-mode t)
(run-mode-hooks 'tt-mode-hook))
(add-to-list 'auto-mode-alist '("\\.tt\\'" . tt-mode))
(provide 'tt-mode)
;;; tt-mode.el ends here