;; Major Mode for editing .tmpl files in Emacs. ;; This file is NOT part of GNU Emacs. ;; ;; To install: ;; 1. Put the file template.el in your Emacs Lisp directory ;; 2. You can byte compile the file icarus.el if you want to ;; 3. Put the following code in your .emacs: ;; (autoload 'template-mode "template") ;; (setq auto-mode-alist ;; (append '(("\\.tmpl$" . template-mode) ;; ("\\.ht$" . template-mode) ;; auto-mode-alist)) ;; 4. And if you don't have a global-font-lock on (emacs 19.32 or later), then ;; also add ;; (add-hook 'template-mode-hook (function 'turn-on-font-lock) (defvar template-font-lock-keywords (list '("\\(\:[a-zA-Z0-9_-]+\\)" 1 font-lock-label-face nil t) '("\\([a-zA-Z0-9_-]+:\\[\\)" 1 font-lock-page-face nil t) '("\\(\$[a-zA-Z0-9_-]+\\)" 1 font-lock-keyword-face t t) '("\\(]*\\)" 1 font-lock-href-face t t) '("\\(]*\\)" 1 font-lock-href-face t t) '("\\(\\)" 1 font-lock-href-face t t) '("\\(\\)" 1 font-lock-href-face t t) '("\\(:=\\)" 1 font-lock-eq-face t t) '("\\(\%[a-zA-Z0-9_-.]+\\)" 1 font-lock-var-face t t) '("\\(#[^\n]*\\)" 1 font-lock-comment-face t t)) "Additional expressions to highlight in Template mode.") (defun template-mode () "Major Mode for editing template files " (interactive) (kill-all-local-variables) (setq mode-name "template") (setq major-mode 'template-mode) ;; Font lock. (make-local-variable 'font-lock-defaults) (make-local-variable 'comment-start) (make-local-variable 'comment-start-skip) (setq comment-start "#") (setq comment-end "") (setq font-lock-defaults '(template-font-lock-keywords)) (run-hooks 'template-mode-hook) ) ;;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ;; Define TEMPLATE face attributes ;;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ (setq font-lock-face-attributes ;;; font-name fgcolor bgcolor bold? slant? underl? '((font-lock-comment-face "springgreen4" nil nil t) (font-lock-keyword-face "firebrick2") (font-lock-label-face "blue4" "lemonchiffon4" nil t) (font-lock-page-face nil "#ff8c00" nil t) (font-lock-href-face "blue" nil nil t) (font-lock-var-face "#a000a0" nil nil t) (font-lock-eq-face "yellow" nil nil t) )) ;#a000a0 (provide 'template-mode)