;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; XEmacs major mode ; ----------------- ; ; Containing: ; - fontlock code for syntactic highlighting of Axiom code ; - a simple syntax table ; ; Author: ; James Cranch ; ; Date: ; 2005/09/09 ; ; Notes: ; This is my first attempt programming elisp, and it ; shows. However, I think this code is not entirely ; useless. ; Since the syntax of axiom is complicated, I suspect ; this code doesn't always do what you want. But if ; you make your files a lot like the standard ones, ; I think you'll be OK. ; ; Things to be done when I have time: ; - Syntactically highlight macros ; - See if more work should be done on the syntax table ; ; Contact: ; If you have any queries/suggestions/problems, send an ; email to jdc41 at cam dot ac dot uk. ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Hook for user-defined code (defvar axiom-mode-hook nil) ;; Axiom keymap (defvar axiom-mode-map (let ((axiom-mode-map (make-keymap))) axiom-mode-map) "Keymap for Axiom major mode") ;; Enter Axiom mode when files ending .spad or .input are edited (add-to-list 'auto-mode-alist '("\\.spad\\'" . axiom-mode)) (add-to-list 'auto-mode-alist '("\\.input\\'" . axiom-mode)) ;; Syntactic highlighting (defconst axiom-font-lock-keywords (list ; Documentation strings. '("\\+\\+.*" 0 font-lock-doc-string-face t t) ; Direct commands '("^).*" . font-lock-preprocessor-face) ; Things being defined: ; - Categories ; (perhaps this should only happen when editing .spad files) '("^\\([A-Z][A-Za-z0-9]*\\)(" 1 font-lock-function-name-face nil t) ; - Functions '("^[ ]*\\(Category\\|\\([A-Za-z0-9]+\\).*==[^>]\\)" 2 font-lock-function-name-face nil t))) ;; Syntax table (defvar axiom-mode-syntax-table (let ((axiom-mode-syntax-table (make-syntax-table))) (modify-syntax-entry ?- "_ 12" axiom-mode-syntax-table) ; perhaps it should be one of . w (modify-syntax-entry ?+ "_" axiom-mode-syntax-table) (modify-syntax-entry ?\n ">" axiom-mode-syntax-table) axiom-mode-syntax-table)) ;; Final definition (defun axiom-mode () (interactive) (kill-all-local-variables) ; (use-local-map axiom-mode-map) (set-syntax-table axiom-mode-syntax-table) ; Set up font-lock (set (make-local-variable 'font-lock-defaults) '(axiom-font-lock-keywords)) ; ; Register our indentation function ; (set (make-local-variable 'indent-line-function) 'axiom-indent-line) (setq major-mode 'axiom-mode) (setq mode-name "Axiom") (run-hooks 'axiom-mode-hook)) (provide 'axiom-mode)