Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Annotation of /sml/trunk/sml-mode/sml-defs.el
ViewVC logotype

Annotation of /sml/trunk/sml-mode/sml-defs.el

Parent Directory Parent Directory | Revision Log Revision Log


Revision 332 - (view) (download)

1 : monnier 319 ;;; sml-move.el
2 :    
3 :     (defconst rcsid-sml-defs "@(#)$Name$:$Id$")
4 :    
5 :     ;; Copyright (C) 1999-1999 Stefan Monnier <monnier@cs.yale.edu>
6 :     ;;
7 :     ;; This program is free software; you can redistribute it and/or modify
8 :     ;; it under the terms of the GNU General Public License as published by
9 :     ;; the Free Software Foundation; either version 2 of the License, or
10 :     ;; (at your option) any later version.
11 :     ;;
12 :     ;; This program is distributed in the hope that it will be useful,
13 :     ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 :     ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 :     ;; GNU General Public License for more details.
16 :     ;;
17 :     ;; You should have received a copy of the GNU General Public License
18 :     ;; along with this program; if not, write to the Free Software
19 :     ;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 :    
21 :     (require 'cl)
22 :     (require 'sml-util)
23 :    
24 :     ;;;
25 :     ;;; Code
26 :     ;;;
27 :    
28 :     (defvar sml-outline-regexp "[ \t]*\\((\\*+\\|\\(let[ \t]+\\)?fun.\\)"
29 :     "Regexp matching a major heading.")
30 :    
31 :     ;;;
32 :     ;;; Internal defines
33 :     ;;;
34 :    
35 :     (defmap sml-bindings
36 :     ;; smarter cursor movement
37 :     '((forward-sexp . sml-user-forward-sexp)
38 :     (backward-sexp . sml-user-backward-sexp)
39 :     ;; Text-formatting commands:
40 :     ("\C-c\C-m" . sml-insert-form)
41 :     ("\C-c\C-i" . sml-mode-info)
42 :     ("\M-|" . sml-electric-pipe)
43 :     ("\;" . sml-electric-semi)
44 :     ("\M-\t" . sml-back-to-outer-indent)
45 :     ("\C-\M-\\" . sml-indent-region)
46 :     ("\t" . sml-indent-line) ; ...except this one
47 :     ;; Process commands added to sml-mode-map -- these should autoload
48 :     ("\C-c\C-l" . sml-load-file)
49 :     ("\C-c`" . sml-next-error))
50 :     "Generic bindings used in sml-mode and sml-inferior-mode.")
51 :    
52 :     (defmap sml-mode-map
53 :     '(("\C-c\C-c" . sml-make)
54 :     ("\C-c\C-s" . switch-to-sml)
55 :     ("\C-c\C-r" . sml-send-region)
56 :     ("\C-c\C-b" . sml-send-buffer))
57 :     "The keymap used in sml-mode."
58 :     :inherit sml-bindings)
59 :    
60 :     (defsyntax sml-mode-syntax-table
61 :     '((?\* . ". 23n")
62 :     (?\( . "()1")
63 :     (?\) . ")(4")
64 :     ("._'" . "_")
65 :     (",;" . ".")
66 :     ;; `!' is not really a prefix-char, oh well!
67 :     ("~#!" . "'")
68 :     ("%&$+-/:<=>?@`^|" . "."))
69 :     "The syntax table used in sml-mode.")
70 :    
71 : monnier 332 (defconst sml-menu
72 :     '("SML"
73 :     ("Process"
74 :     ["Start default ML compiler" sml :active (fboundp 'sml)]
75 :     ["-" nil nil]
76 :     ["run CM.make" sml-make :active (featurep 'sml-proc)]
77 :     ["load ML source file" sml-load-file :active (featurep 'sml-proc)]
78 :     ["switch to ML buffer" switch-to-sml :active (featurep 'sml-proc)]
79 :     ["--" nil nil]
80 :     ["send buffer contents" sml-send-buffer :active (featurep 'sml-proc)]
81 :     ["send region" sml-send-region :active (featurep 'sml-proc)]
82 :     ["send paragraph" sml-send-function :active (featurep 'sml-proc)]
83 :     ["goto next error" sml-next-error :active (featurep 'sml-proc)]
84 :     ["---" nil nil]
85 :     ["Standard ML of New Jersey" sml-smlnj :active (fboundp 'sml-smlnj)]
86 :     ["Poly/ML" sml-poly-ml :active (fboundp 'sml-poly-ml)]
87 :     ["Moscow ML" sml-mosml :active (fboundp 'sml-mosml)]
88 :     ["Help for Inferior ML" (describe-function 'inferior-sml-mode) :active (featurep 'sml-proc)])
89 :     ["electric pipe" sml-electric-pipe t]
90 :     ["insert SML form" sml-insert-form t]
91 :     ("Forms"
92 :     ["abstype" sml-form-abstype t]
93 :     ["datatype" sml-form-datatype t]
94 :     ["-" nil nil]
95 :     ["let" sml-form-let t]
96 :     ["local" sml-form-local t]
97 :     ["case" sml-form-case t]
98 :     ["--" nil nil]
99 :     ["signature" sml-form-signature t]
100 :     ["functor" sml-form-functor t]
101 :     ["structure" sml-form-structure t])
102 :     ("Format/Mode Variables"
103 :     ["indent region" sml-indent-region t]
104 :     ["outdent" sml-back-to-outer-indent t]
105 :     ["-" nil nil]
106 :     ["set indent-level" sml-indent-level t]
107 :     ["set pipe-indent" sml-pipe-indent t]
108 :     ["--" nil nil]
109 :     ["toggle type-of-indent" (sml-type-of-indent) t]
110 :     ["toggle nested-if-indent" (sml-nested-if-indent) t]
111 :     ["toggle case-indent" (sml-case-indent) t]
112 :     ["toggle electric-semi-mode" (sml-electric-semi-mode) t])
113 :     ["-----" nil nil]
114 :     ["SML mode help (brief)" describe-mode t]
115 :     ["SML mode *info*" sml-mode-info t]
116 :     ["SML mode version" sml-mode-version t]
117 :     ["-----" nil nil]
118 :     ["Remove overlay" (sml-error-overlay 'undo) :active (sml-overlay-active-p)]))
119 :    
120 :     (when (ignore-errors (require 'easymenu))
121 :     (easy-menu-define sml-mode-menu
122 :     sml-mode-map
123 :     "Menu used in sml-mode."
124 :     sml-menu))
125 :    
126 :     ;;; Make's sure they appear in the menu bar when sml-mode-map is active.
127 :     ;; On the hook for XEmacs only -- see easy-menu-add in auc-menu.el.
128 :     ;; (defun sml-mode-menu-bar ()
129 :     ;; "Make sure menus appear in the menu bar as well as under mouse 3."
130 :     ;; (and (eq major-mode 'sml-mode)
131 :     ;; (easy-menu-add sml-mode-menu sml-mode-map)))
132 :     ;; (add-hook 'sml-mode-hook 'sml-mode-menu-bar)
133 :    
134 : monnier 319 ;;
135 :     ;; regexps
136 :     ;;
137 :    
138 :     (defun sml-syms-re (&rest syms)
139 :     (concat "\\<" (regexp-opt (flatten syms) t) "\\>"))
140 :    
141 :     ;;
142 :    
143 :     (defconst sml-module-head-syms
144 :     '("signature" "structure" "functor" "abstraction"))
145 :    
146 :     (defconst sml-begin-symbols-re
147 :     (sml-syms-re "let" "abstype" "local" "struct" "sig")
148 :     "Symbols matching the `end' symbol.")
149 :    
150 :     ;; (defconst sml-user-begin-symbols-re
151 :     ;; (sml-syms-re "let" "abstype" "local" "struct" "sig" "in" "with")
152 :     ;; "Symbols matching (loosely) the `end' symbol.")
153 :    
154 :     (defconst sml-sexp-head-symbols-re
155 :     (sml-syms-re "let" "abstype" "local" "struct" "sig" "in" "with"
156 :     "if" "then" "else" "case" "of" "fn" "fun" "val" "and"
157 :     sml-module-head-syms
158 :     "handle" "raise")
159 :     "Symbols starting an sexp.")
160 :    
161 :     ;; (defconst sml-not-arg-start-re
162 :     ;; (sml-syms-re "in" "of" "end" "andalso")
163 :     ;; "Symbols that can't be found at the head of an arg.")
164 :    
165 :     ;; (defconst sml-not-arg-re
166 :     ;; (sml-syms-re "in" "of" "end" "andalso")
167 :     ;; "Symbols that should not be confused with an arg.")
168 :    
169 :     (defconst sml-indent-starters
170 :     (list
171 :     (cons "\\<struct\\>" 0)
172 :     (cons (sml-syms-re sml-module-head-syms) '(sml-indent-level 0))
173 :     (cons "\\<local\\>" '(sml-indent-level 0))
174 :     (cons "\\<of\\>" '(3 nil))
175 :     (cons "\\<else\\>" '(sml-indent-level 0))
176 : monnier 332 (cons "\\<in\\|fun\\|and\\>" '(sml-indent-level nil))
177 :     (cons (sml-syms-re "abstype" "case" "datatype"
178 :     "if" "then" "else" "sharing" "infix" "infixr"
179 :     "let" "local" "nonfix" "open" "raise" "sig"
180 : monnier 319 "struct" "type" "val" "while" "do" "with" "withtype")
181 :     'sml-indent-level))
182 :     "")
183 :    
184 :     (defconst sml-starters-indent-after
185 :     (sml-syms-re "let" "local" "struct" "in" "sig" "with")
186 :     "Indent after these.")
187 :    
188 :     (defconst sml-=-starter-re
189 :     (sml-syms-re "val" "fun" "and" "datatype" "type" "abstype" "eqtype"
190 :     sml-module-head-syms)
191 :     "keywords which can be followed by a `='")
192 :    
193 :     (defconst sml-delegate
194 :     (list
195 :     (cons (sml-syms-re "of" "else" "then") '(not (sml-bolp)))
196 :     (cons "\\<in\\>" t))
197 :     "Words which might delegate indentation to their parent.")
198 :    
199 :     (defconst sml-starters-syms
200 :     (append sml-module-head-syms
201 :     '("abstype" "datatype" "exception" "fun"
202 :     "local" "infix" "infixr" "sharing" "nonfix"
203 :     "open" "type" "val" "and"
204 :     "withtype" "with"))
205 :     "The starters of new expressions.")
206 :     (defconst sml-starters-re (sml-syms-re sml-starters-syms))
207 :    
208 :     (defconst sml-exptrail-syms
209 :     '("if" "then" "else" "while" "do" "case" "of" "raise" "fn"))
210 :    
211 :     (defconst sml-pipehead-re
212 :     (sml-syms-re "fun" "fn" "and" "handle" "case" "datatype" "abstype")
213 :     "A `|' corresponds to one of these.")
214 :    
215 :     ;;
216 :     (provide 'sml-defs)

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0