author | Tony Garnock-Jones <tonyg@kcbbs.gen.nz> |
Fri, 21 Oct 2005 19:30:54 +1300 | |
changeset 34 | 570a02bb7a27 |
parent 33 | ca497a9ada93 |
child 35 | 0415292cf581 |
permissions | -rw-r--r-- |
33 | 1 |
;;; tng-r3.el --- ThiNG r3 code editing commands for Emacs |
2 |
||
3 |
;; Add code like the following to your .emacs to install: |
|
4 |
;; (autoload 'tng-r3-mode "...path.to.wherever.you.put.this.file.../tng-r3.el" nil t) |
|
5 |
;; (setq auto-mode-alist (cons '("\\.tng\\'" . tng-r3-mode) |
|
6 |
;; auto-mode-alist)) |
|
7 |
||
8 |
;; Copyright (C) 1988,94,96,2000 Free Software Foundation, Inc. |
|
9 |
;; Copyright (C) 2003, 2005 Tony Garnock-Jones <tonyg@lshift.net> |
|
10 |
||
11 |
;; This file is based on GNU Emacs' AWK mode (awk-mode.el). |
|
12 |
||
13 |
;; This is free software; you can redistribute it and/or modify |
|
14 |
;; it under the terms of the GNU General Public License as published by |
|
15 |
;; the Free Software Foundation; either version 2, or (at your option) |
|
16 |
;; any later version. |
|
17 |
||
18 |
;; This is distributed in the hope that it will be useful, |
|
19 |
;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
20 |
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
21 |
;; GNU General Public License for more details. |
|
22 |
||
23 |
;; You should have received a copy of the GNU General Public License |
|
24 |
;; along with this software; see the file COPYING. If not, write to the |
|
25 |
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
|
26 |
;; Boston, MA 02111-1307, USA. |
|
27 |
||
28 |
(require 'cc-mode) |
|
29 |
||
30 |
(defvar tng-r3-mode-syntax-table nil |
|
31 |
"Syntax table in use in tng-r3-mode buffers.") |
|
32 |
||
33 |
(if tng-r3-mode-syntax-table |
|
34 |
() |
|
35 |
(setq tng-r3-mode-syntax-table (make-syntax-table)) |
|
36 |
(cond ((memq '8-bit c-emacs-features) ;; XEmacs |
|
37 |
(modify-syntax-entry ?\" "! " tng-r3-mode-syntax-table)) |
|
38 |
((memq '1-bit c-emacs-features) ;; Proper Emacs |
|
39 |
(modify-syntax-entry ?\" "! " tng-r3-mode-syntax-table))) |
|
40 |
(modify-syntax-entry ?_ "_" tng-r3-mode-syntax-table) |
|
41 |
(mapcar #'(lambda (x) (modify-syntax-entry x "." tng-r3-mode-syntax-table)) |
|
42 |
'(?, ?\; ?- ?+ ?= ?| ?/ ?? ?. ?< ?> ?* ?& ?^ ?% ?$ ?# ?@ ?! ?` ?~)) |
|
43 |
(modify-syntax-entry ?\' "\"" tng-r3-mode-syntax-table)) |
|
44 |
||
45 |
(defconst tng-r3-font-lock-keywords |
|
46 |
(eval-when-compile |
|
47 |
(list |
|
48 |
'(";;" . font-lock-warning-face) |
|
49 |
||
34
570a02bb7a27
New, more uniform syntax. Evaluator needs updating.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
33
diff
changeset
|
50 |
;; Atoms. |
570a02bb7a27
New, more uniform syntax. Evaluator needs updating.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
33
diff
changeset
|
51 |
'("#\\<\\([-a-zA-Z0-9+=_|/?.<>*&^%$@!`~]\\)*\\>" . font-lock-constant-face) |
570a02bb7a27
New, more uniform syntax. Evaluator needs updating.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
33
diff
changeset
|
52 |
|
33 | 53 |
;; Keywords. |
34
570a02bb7a27
New, more uniform syntax. Evaluator needs updating.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
33
diff
changeset
|
54 |
'("\\<define\\([-a-zA-Z0-9+=_|/?.<>*&^%$@!`~]\\)*\\>" . font-lock-keyword-face) |
570a02bb7a27
New, more uniform syntax. Evaluator needs updating.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
33
diff
changeset
|
55 |
'("\\<\\(new\\)\\s \\([a-zA-Z]\\([-a-zA-Z0-9+=_|/?.<>*&^%$@!`~]\\|::\\)*\\)\\>" |
33 | 56 |
(1 font-lock-keyword-face) (2 font-lock-type-face)) |
57 |
(regexp-opt |
|
58 |
'( |
|
59 |
"define" |
|
60 |
"in" |
|
61 |
"let" |
|
62 |
"letrec" |
|
63 |
"module" |
|
64 |
"new" |
|
34
570a02bb7a27
New, more uniform syntax. Evaluator needs updating.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
33
diff
changeset
|
65 |
"return" |
33 | 66 |
) |
67 |
'words) |
|
68 |
||
69 |
;; Namespaces. |
|
34
570a02bb7a27
New, more uniform syntax. Evaluator needs updating.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
33
diff
changeset
|
70 |
'("\\<[A-Z]\\([-a-zA-Z0-9+=_|/?.<>*&^%$@!`~]\\)*\\>::" . font-lock-type-face) |
33 | 71 |
|
34
570a02bb7a27
New, more uniform syntax. Evaluator needs updating.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
33
diff
changeset
|
72 |
;; Types. |
570a02bb7a27
New, more uniform syntax. Evaluator needs updating.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
33
diff
changeset
|
73 |
'("\\<[A-Z]\\([-a-zA-Z0-9+=_|/?.<>*&^%$@!`~]\\)*\\>" . font-lock-type-face) |
570a02bb7a27
New, more uniform syntax. Evaluator needs updating.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
33
diff
changeset
|
74 |
|
570a02bb7a27
New, more uniform syntax. Evaluator needs updating.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
33
diff
changeset
|
75 |
;; Functions. |
570a02bb7a27
New, more uniform syntax. Evaluator needs updating.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
33
diff
changeset
|
76 |
'("(\\(\\<[a-zA-Z]\\([-a-zA-Z0-9+=_|/?.<>*&^%$@!`~]\\)*\\>\\)\\($\\|\\s [^-+=_|/?.<>*&^%$@!`~#]\\)" |
570a02bb7a27
New, more uniform syntax. Evaluator needs updating.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
33
diff
changeset
|
77 |
(1 font-lock-function-name-face)) |
33 | 78 |
|
79 |
;; Variables. |
|
34
570a02bb7a27
New, more uniform syntax. Evaluator needs updating.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
33
diff
changeset
|
80 |
'("\\<[a-zA-Z]\\([-a-zA-Z0-9+=_|/?.<>*&^%$@!`~]\\)*\\>" . font-lock-variable-name-face) |
33 | 81 |
|
82 |
;; Infixops. |
|
34
570a02bb7a27
New, more uniform syntax. Evaluator needs updating.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
33
diff
changeset
|
83 |
'("\\<[-+=_|/?.<>*&^%$@!`~]\\([-a-zA-Z0-9+=_|/?.<>*&^%$@!`~]\\)*\\>" |
33 | 84 |
. font-lock-function-name-face) |
85 |
)) |
|
86 |
"Default expressions to highlight in TNG-R3 mode.") |
|
87 |
||
88 |
;;;###autoload |
|
89 |
(define-derived-mode tng-r3-mode c-mode "TNG-R3" |
|
90 |
"Major mode for editing TNG-R3 code. |
|
91 |
This is much like C mode except for the syntax of comments. Its keymap |
|
92 |
inherits from C mode's and it has the same variables for customizing |
|
93 |
indentation. It has its own abbrev table and its own syntax table. |
|
94 |
||
95 |
Turning on TNG-R3 mode runs `tng-r3-mode-hook'." |
|
96 |
(make-local-variable 'comment-start) |
|
97 |
(make-local-variable 'comment-end) |
|
98 |
(make-local-variable 'comment-start-skip) |
|
99 |
(setq comment-start "\"") |
|
100 |
(setq comment-end "\"") |
|
101 |
(setq comment-start-skip "\" *") |
|
102 |
(make-local-variable 'c-syntactic-indentation) |
|
103 |
(setq c-syntactic-indentation nil) |
|
104 |
(make-local-variable 'font-lock-defaults) |
|
105 |
(setq font-lock-defaults '(tng-r3-font-lock-keywords nil nil ((?_ . "w"))))) |
|
106 |
||
107 |
(provide 'tng-r3-mode) |
|
108 |
||
109 |
;;; tng-r3.el ends here |