smalltalk-tng
view r2/tng-r2.el @ 323:454c18798969
merger
| author | Tony Garnock-Jones <tonygarnockjones@gmail.com> |
|---|---|
| date | Tue Feb 07 11:34:20 2012 -0500 (3 months ago) |
| parents | 9b9bd39d5e13 |
| children |
line source
1 ;;; tng-r2.el --- ThiNG r2 code editing commands for Emacs
3 ;; Add code like the following to your .emacs to install:
4 ;; (autoload 'tng-r2-mode "...path.to.wherever.you.put.this.file.../tng-r2.el" nil t)
5 ;; (setq auto-mode-alist (cons '("\\.tng\\'" . tng-r2-mode)
6 ;; auto-mode-alist))
8 ;; Copyright (C) 1988,94,96,2000 Free Software Foundation, Inc.
9 ;; Copyright (C) 2003, 2005 Tony Garnock-Jones <tonyg@lshift.net>
11 ;; This file is based on GNU Emacs' AWK mode (awk-mode.el).
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.
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.
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.
28 (require 'cc-mode)
30 (defvar tng-r2-mode-syntax-table nil
31 "Syntax table in use in tng-r2-mode buffers.")
33 (if tng-r2-mode-syntax-table
34 ()
35 (setq tng-r2-mode-syntax-table (make-syntax-table))
36 (cond ((memq '8-bit c-emacs-features) ;; XEmacs
37 (modify-syntax-entry ?\" "! " tng-r2-mode-syntax-table))
38 ((memq '1-bit c-emacs-features) ;; Proper Emacs
39 (modify-syntax-entry ?\" "! " tng-r2-mode-syntax-table)))
40 (modify-syntax-entry ?_ "_" tng-r2-mode-syntax-table)
41 (mapcar #'(lambda (x) (modify-syntax-entry x "." tng-r2-mode-syntax-table))
42 '(?, ?\; ?- ?+ ?= ?| ?/ ?? ?. ?< ?> ?* ?& ?^ ?% ?$ ?# ?@ ?! ?` ?~))
43 (modify-syntax-entry ?\' "\"" tng-r2-mode-syntax-table))
45 (defconst tng-r2-font-lock-keywords
46 (eval-when-compile
47 (list
48 '(";;" . font-lock-warning-face)
50 ;; Keywords.
51 '("\\<define\\([-a-zA-Z0-9+=_|/?.<>*&^%$#@!`~]\\)*\\>" . font-lock-keyword-face)
52 '("\\<\\(new\\)\\s \\([A-Z]\\([-a-zA-Z0-9+=_|/?.<>*&^%$#@!`~]\\|::\\)*\\)\\>"
53 (1 font-lock-keyword-face) (2 font-lock-type-face))
54 (regexp-opt
55 '(
56 "define"
57 "in"
58 "let"
59 "letrec"
60 "module"
61 "new"
62 )
63 'words)
65 ;; Namespaces.
66 '("\\<[A-Z]\\([-a-zA-Z0-9+=_|/?.<>*&^%$#@!`~]\\)*\\>::" . font-lock-type-face)
68 ;; Atoms.
69 '("\\<[A-Z]\\([-a-zA-Z0-9+=_|/?.<>*&^%$#@!`~]\\)*\\>" . font-lock-constant-face)
71 ;; Variables.
72 '("\\<[a-z]\\([-a-zA-Z0-9+=_|/?.<>*&^%$#@!`~]\\)*\\>" . font-lock-variable-name-face)
74 ;; Infixops.
75 '("\\<[-+=_|/?.<>*&^%$#@!`~]\\([-a-zA-Z0-9+=_|/?.<>*&^%$#@!`~]\\)*\\>"
76 . font-lock-function-name-face)
77 ))
78 "Default expressions to highlight in TNG-R2 mode.")
80 ;;;###autoload
81 (define-derived-mode tng-r2-mode c-mode "TNG-R2"
82 "Major mode for editing TNG-R2 code.
83 This is much like C mode except for the syntax of comments. Its keymap
84 inherits from C mode's and it has the same variables for customizing
85 indentation. It has its own abbrev table and its own syntax table.
87 Turning on TNG-R2 mode runs `tng-r2-mode-hook'."
88 (make-local-variable 'comment-start)
89 (make-local-variable 'comment-end)
90 (make-local-variable 'comment-start-skip)
91 (setq comment-start "\"")
92 (setq comment-end "\"")
93 (setq comment-start-skip "\" *")
94 (make-local-variable 'c-syntactic-indentation)
95 (setq c-syntactic-indentation nil)
96 (make-local-variable 'font-lock-defaults)
97 (setq font-lock-defaults '(tng-r2-font-lock-keywords nil nil ((?_ . "w")))))
99 (provide 'tng-r2-mode)
101 ;;; tng-r2.el ends here
