[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Axiom-developer] BOOT mode for Emacs
From: |
Kai Kaminski |
Subject: |
[Axiom-developer] BOOT mode for Emacs |
Date: |
Mon, 18 Jul 2005 17:49:53 +0200 |
User-agent: |
Mozilla Thunderbird 1.0.2 (Macintosh/20050317) |
Hi,
I put together a tiny Emacs mode for BOOT code. It doesn't do much, but
comment-region and font-locking work to some extent, which is all I need
right now. It's my first Emacs mode ever, so it might not work very
well. I also haven't tested it with XEmacs yet.
Kai
PS: I hope I didn't duplicate any effort. I couldn't find anything in
the axiom-developer archive.
;;;; Emacs mode for BOOT, an undocumented, paren-less
;;;; version of Lisp used by Axiom, the Computer Algebra System
;;;; with a thirty year horizon.
;; Copyright 2005 Kai Kaminski <kai.kaminski at gmail.com>
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, write to the Free Software
;; Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
(require 'font-lock)
(defvar boot-mode-syntax-table nil "Syntax table for the BOOT major mode")
(setq boot-mode-syntax-table (make-syntax-table))
(modify-syntax-entry ?\( "()" boot-mode-syntax-table)
(modify-syntax-entry ?\) ")(" boot-mode-syntax-table)
(modify-syntax-entry ?\$ "_" boot-mode-syntax-table)
(modify-syntax-entry ?\= "." boot-mode-syntax-table)
(modify-syntax-entry ?\- "w 12b" boot-mode-syntax-table)
(modify-syntax-entry ?\_ "w" boot-mode-syntax-table)
(modify-syntax-entry ?\: "." boot-mode-syntax-table)
(modify-syntax-entry ?\< "." boot-mode-syntax-table)
(modify-syntax-entry ?\> "." boot-mode-syntax-table)
(modify-syntax-entry ?\' "." boot-mode-syntax-table)
(modify-syntax-entry ?\" "\"" boot-mode-syntax-table)
(modify-syntax-entry ?\n "> b" boot-mode-syntax-table)
(defvar boot-mode-font-lock-keywords
(let ((keywords
(mapconcat 'identity
'("and" "or" "not" "while" "for" "in" "repeat"
"local" "fluid" "true" "false" "nil" "if" "then")
"\\b\\|\\b")))
(list
;; Keywords, like 'if', 'when' etc
(cons (concat "\\(\\b" keywords "\\b\\)") 1)
;; function names found as 'foo('
(list "\\b\\([a-zA-Z][a-zA-Z0-9*_-]*\\)(" 1 font-lock-function-name-face)
;; function names in functions definitions, i.e 'foo param1 ... paramN =='
(list "^\\([a-zA-Z]+\\) .*==.*$" 1 font-lock-function-name-face)
;; function application without parens, like 'foo param'. Doesn't work
properly and messes up comments.
;; (list "\\(^\\|\\s.\\|\\)\\s-*\\([a-zA-Z][a-zA-Z_-]*\\) +[a-zA-Z]" 2
font-lock-function-name-face t)
(list "\\(\\$[a-zA-Z0-9]+\\)" 1 font-lock-variable-name-face)
(list "\\b\\([a-zA-Z][a-zA-Z0-9*_-]*\\)\\b" 1
font-lock-variable-name-face))))
(defun boot-mode ()
"Major mode for editing BOOT code used by Axiom, the Computer
Algebra System with a thirty year horizon.
Commands:
\\{boot-mode-map}
Entry to this mode runs the hook 'boot-mode-hook'."
(interactive)
(kill-all-local-variables)
(make-local-variable 'comment-start)
(make-local-variable 'comment-start-skip)
(make-local-variable 'paragraph-start)
(make-local-variable 'font-lock-defaults)
(set-syntax-table boot-mode-syntax-table)
(setq major-mode 'boot-mode
mode-name "BOOT"
font-lock-defaults '(boot-mode-font-lock-keywords nil t)
paragraph-start "^[ \t]*$"
comment-start "--"
comment-start-skip "--")
;; (use-local-map boot-mode-map)
(run-hooks 'boot-mode-hook))
(run-hooks 'boot-mode-load-hook)
(provide 'boot-mode)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Axiom-developer] BOOT mode for Emacs,
Kai Kaminski <=