;;; xplain-mode.el --- Mode for editing Xplain data definition and ;;; data manipulation files ;; ;; $Revision: 1.2 $ ;; ;; Author: Berend de Boer ;; Keywords: Xplain ;; URL: http://www.pobox.com/~berend/Xplain/xplain-mode.el ;;; Commentary: ;; ;; Syntax hightlighting makes creating Xplain databases even more pleasant. ;; ;; Add this to your .emacs file to load and bind it to files with extension ;; .ddl: ;; (add-to-list 'auto-mode-alist '("\\.ddl\\'" . xplain-mode)) ;;(autoload 'xplain-mode "xplain-mode" "Major mode for Xplain programs" t) ;;; Known bugs: ;; 1. SQL code region not detected nor highlighted ;;; Code: (defgroup xplain nil "Major mode for editing Xplain source in Emacs" :group 'languages) ;; (defvar xplain-load-hook nil "*Hook run when the xplain-mode is loaded.") ;; (defvar xplain-font-lock-keywords (let ((xplain-keywords (eval-when-compile (concat "\\b" (regexp-opt '( "and" "any" "assert" "base" "cascade" "case" "check" "constant" "database" "default" "delete" "echo" "else" "end" "extend" "get" "if" "init" "input" "insert" "its" "loginname" "max" "min" "newline" "nil" "not" "null" "of" "or" "per" "purge" "some" "systemdate" "then" "true" "type" "update" "value" "with" "where" ) t) "\\b"))) (xplain-extra-keywords (eval-when-compile (concat "\\b" (regexp-opt '( "as" "clustered" "index" "optional" "required" "unique" ) t) "\\b"))) (xplain-types "\(\\(A\\|B\\|D\\|I\\|M\\|P\\|R\\|T\\|V\\)[0-9,]*\)")) (setq xplain-font-lock-keywords (list (cons "^#.*$" 'font-lock-comment-face) (cons ".include " font-lock-reference-face) (cons "\`[^\']+\'" font-lock-builtin-face) (cons "\"[^\"]*\"" 'font-lock-string-face) (cons "\{[^\}]*\}" 'font-lock-function-name-face) (cons xplain-keywords 'font-lock-keyword-face) (cons xplain-extra-keywords 'font-lock-keyword-face) (cons xplain-types 'font-lock-type-face) ))) "Info for function `font-lock-mode'." ) ;;;###autoload (defun xplain-mode () "Major mode for editing Xplain data definition/manipulation files." (interactive) ;; (kill-all-local-variables) (setq mode-name "Xplain") (setq major-mode 'xplain-mode) ;; (setq comment-start "#") (setq comment-start-skip "#+ *") ;; (make-local-variable 'font-lock-defaults) (setq font-lock-defaults '(xplain-font-lock-keywords)) (make-local-variable 'font-lock-keywords-case-fold-search) (setq font-lock-keywords-case-fold-search t) (make-local-variable 'font-lock-beginning-of-syntax-function) (setq font-lock-beginning-of-syntax-function 'beginning-of-line) (make-local-variable 'font-lock-keywords-only) (setq font-lock-keywords-only t) ;; (run-hooks 'xplain-mode-hook) ) (provide 'xplain-mode) (run-hooks 'xplain-load-hook) ;;; xplain-mode.el ends here