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 347 - (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 : monnier 341 ("\C-c\C-m" . sml-insert-form)
41 :     ("\C-c\C-i" . sml-mode-info)
42 :     ("\M-|" . sml-electric-pipe)
43 :     ("\M-\ " . sml-electric-pipe)
44 :     ("\;" . sml-electric-semi)
45 :     ("\M-\t" . sml-back-to-outer-indent)
46 : monnier 347 ;;("\C-\M-\\" . sml-indent-region)
47 :     ;;("\t" . sml-indent-line) ; ...except this one
48 : monnier 319 ;; Process commands added to sml-mode-map -- these should autoload
49 : monnier 341 ("\C-c\C-l" . sml-load-file)
50 :     ("\C-c`" . sml-next-error))
51 : monnier 319 "Generic bindings used in sml-mode and sml-inferior-mode.")
52 :    
53 :     (defmap sml-mode-map
54 : monnier 333 '(("\C-c\C-c" . sml-compile)
55 : monnier 319 ("\C-c\C-s" . switch-to-sml)
56 :     ("\C-c\C-r" . sml-send-region)
57 :     ("\C-c\C-b" . sml-send-buffer))
58 :     "The keymap used in sml-mode."
59 :     :inherit sml-bindings)
60 :    
61 :     (defsyntax sml-mode-syntax-table
62 :     '((?\* . ". 23n")
63 :     (?\( . "()1")
64 :     (?\) . ")(4")
65 :     ("._'" . "_")
66 :     (",;" . ".")
67 :     ;; `!' is not really a prefix-char, oh well!
68 :     ("~#!" . "'")
69 :     ("%&$+-/:<=>?@`^|" . "."))
70 :     "The syntax table used in sml-mode.")
71 :    
72 : monnier 334
73 :    
74 :     (easy-menu-define sml-mode-menu sml-mode-map "Menu used in sml-mode."
75 : monnier 332 '("SML"
76 :     ("Process"
77 : monnier 334 ["Start default ML compiler" sml (fboundp 'sml)]
78 :     ["-" nil nil]
79 :     ["run CM.make" sml-make (featurep 'sml-proc)]
80 :     ["load ML source file" sml-load-file (featurep 'sml-proc)]
81 :     ["switch to ML buffer" switch-to-sml (featurep 'sml-proc)]
82 :     ["--" nil nil]
83 :     ["send buffer contents" sml-send-buffer (featurep 'sml-proc)]
84 :     ["send region" sml-send-region (featurep 'sml-proc)]
85 :     ["send paragraph" sml-send-function (featurep 'sml-proc)]
86 :     ["goto next error" sml-next-error (featurep 'sml-proc)]
87 :     ["---" nil nil]
88 :     ["Standard ML of New Jersey" sml-smlnj (fboundp 'sml-smlnj)]
89 :     ["Poly/ML" sml-poly-ml (fboundp 'sml-poly-ml)]
90 :     ["Moscow ML" sml-mosml (fboundp 'sml-mosml)]
91 : monnier 332 ["Help for Inferior ML" (describe-function 'inferior-sml-mode) :active (featurep 'sml-proc)])
92 :     ["electric pipe" sml-electric-pipe t]
93 :     ["insert SML form" sml-insert-form t]
94 : monnier 334 ("Forms" :filter sml-forms-menu)
95 : monnier 332 ("Format/Mode Variables"
96 :     ["indent region" sml-indent-region t]
97 :     ["outdent" sml-back-to-outer-indent t]
98 :     ["-" nil nil]
99 :     ["set indent-level" sml-indent-level t]
100 :     ["set pipe-indent" sml-pipe-indent t]
101 :     ["--" nil nil]
102 :     ["toggle type-of-indent" (sml-type-of-indent) t]
103 :     ["toggle nested-if-indent" (sml-nested-if-indent) t]
104 :     ["toggle case-indent" (sml-case-indent) t]
105 :     ["toggle electric-semi-mode" (sml-electric-semi-mode) t])
106 :     ["-----" nil nil]
107 :     ["SML mode help (brief)" describe-mode t]
108 :     ["SML mode *info*" sml-mode-info t]
109 :     ["SML mode version" sml-mode-version t]
110 :     ["-----" nil nil]
111 :     ["Remove overlay" (sml-error-overlay 'undo) :active (sml-overlay-active-p)]))
112 :    
113 :     ;;; Make's sure they appear in the menu bar when sml-mode-map is active.
114 :     ;; On the hook for XEmacs only -- see easy-menu-add in auc-menu.el.
115 :     ;; (defun sml-mode-menu-bar ()
116 :     ;; "Make sure menus appear in the menu bar as well as under mouse 3."
117 :     ;; (and (eq major-mode 'sml-mode)
118 :     ;; (easy-menu-add sml-mode-menu sml-mode-map)))
119 :     ;; (add-hook 'sml-mode-hook 'sml-mode-menu-bar)
120 :    
121 : monnier 319 ;;
122 :     ;; regexps
123 :     ;;
124 :    
125 : monnier 347 (defvar sml-fixindent-re
126 :     (concat ".*" (regexp-quote comment-start)
127 :     "[ \t]*fixindent[ \t]*"
128 :     (regexp-quote comment-end))
129 :     "Regexp matching the magic string overriding indentation.")
130 :    
131 :     ;;
132 :    
133 : monnier 319 (defun sml-syms-re (&rest syms)
134 :     (concat "\\<" (regexp-opt (flatten syms) t) "\\>"))
135 :    
136 :     ;;
137 :    
138 :     (defconst sml-module-head-syms
139 :     '("signature" "structure" "functor" "abstraction"))
140 :    
141 : monnier 334
142 :     (defconst sml-begin-syms
143 :     '("let" "abstype" "local" "struct" "sig")
144 :     "Symbols matching the `end' symbol.")
145 :    
146 : monnier 342 (defconst sml-begin-syms-re
147 : monnier 319 (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 : monnier 334 "datatype" "type" "exception" "open" "infix" "infixr" "nonfix"
158 : monnier 319 sml-module-head-syms
159 :     "handle" "raise")
160 :     "Symbols starting an sexp.")
161 :    
162 :     ;; (defconst sml-not-arg-start-re
163 :     ;; (sml-syms-re "in" "of" "end" "andalso")
164 :     ;; "Symbols that can't be found at the head of an arg.")
165 :    
166 :     ;; (defconst sml-not-arg-re
167 :     ;; (sml-syms-re "in" "of" "end" "andalso")
168 :     ;; "Symbols that should not be confused with an arg.")
169 :    
170 : monnier 334 (defconst sml-=-starter-syms
171 :     (list* "|" "val" "fun" "and" "datatype" "type" "abstype" "eqtype"
172 :     sml-module-head-syms)
173 :     "Symbols that can be followed by a `='.")
174 :     (defconst sml-=-starter-re
175 :     (concat "\\S.|\\S.\\|" (sml-syms-re (cdr sml-=-starter-syms)))
176 :     "Symbols that can be followed by a `='.")
177 :    
178 :     (defconst sml-indent-rule
179 :     (sml-preproc-alist
180 :     `(("struct" . 0)
181 : monnier 339 (,sml-module-head-syms "d=" 0)
182 :     ("local" "in" 0)
183 : monnier 334 ;;("of" . (3 nil))
184 :     ;;("else" . (sml-indent-level 0))
185 :     ;;(("in" "fun" "and" "of") . (sml-indent-level nil))
186 : monnier 339 ("if" "else" 0)
187 :     (,sml-=-starter-syms nil)
188 : monnier 334 (("abstype" "case" "datatype" "if" "then" "else" "sharing" "infix" "infixr"
189 :     "let" "local" "nonfix" "open" "raise" "sig" "struct" "type" "val" "while"
190 :     "do" "with" "withtype"))))
191 : monnier 319 "")
192 :    
193 :     (defconst sml-starters-indent-after
194 :     (sml-syms-re "let" "local" "struct" "in" "sig" "with")
195 :     "Indent after these.")
196 :    
197 :     (defconst sml-delegate
198 : monnier 334 (sml-preproc-alist
199 :     `((("of" "else" "then" "d=") . (not (sml-bolp)))
200 :     ("in" . t)))
201 : monnier 319 "Words which might delegate indentation to their parent.")
202 :    
203 : monnier 334 (defconst sml-symbol-indent
204 :     '(("fn" . -3)
205 :     ("of" . 1)
206 : monnier 341 ("|" . -2)
207 : monnier 334 ;;("in" . 1)
208 :     ("d=" . 2))
209 :     "Special indentation alist for some symbols.")
210 :    
211 :     (defconst sml-open-paren
212 :     (sml-preproc-alist
213 : monnier 342 `((,(list* "with" "in" sml-begin-syms) ,sml-begin-syms-re "\\<end\\>")))
214 : monnier 334 "Symbols that should behave somewhat like opening parens.")
215 :    
216 :     (defconst sml-close-paren
217 : monnier 339 `(("in" "\\<l\\(ocal\\|et\\)\\>")
218 :     ("with" "\\<abstype\\>")
219 :     ("withtype" "\\<\\(abs\\|data\\)type\\>")
220 : monnier 342 ("end" ,sml-begin-syms-re)
221 : monnier 339 ("then" "\\<if\\>")
222 :     ("else" "\\<if\\>" (sml-bolp))
223 :     ("of" "\\<case\\>")
224 :     ("d=" nil))
225 : monnier 334 "Symbols that should behave somewhat like close parens.")
226 :    
227 :     (defconst sml-agglomerate-re "\\<else[ \t]+if\\>"
228 :     "Regexp of compound symbols (pairs of symbols to be considered as one).")
229 :    
230 :     (defconst sml-non-nested-of-starter-re
231 :     (sml-syms-re "datatype" "abstype" "exception")
232 :     "Symbols that can introduce an `of' that shouldn't behave like a paren.")
233 :    
234 : monnier 319 (defconst sml-starters-syms
235 :     (append sml-module-head-syms
236 :     '("abstype" "datatype" "exception" "fun"
237 :     "local" "infix" "infixr" "sharing" "nonfix"
238 :     "open" "type" "val" "and"
239 :     "withtype" "with"))
240 :     "The starters of new expressions.")
241 :     (defconst sml-starters-re (sml-syms-re sml-starters-syms))
242 :    
243 :     (defconst sml-exptrail-syms
244 : monnier 334 '("if" "then" "else" "while" "withtype" "do" "case" "of" "raise" "fn"))
245 : monnier 319
246 :     (defconst sml-pipehead-re
247 : monnier 334 (concat
248 :     "|\\S.\\|"
249 :     (sml-syms-re "of" "fun" "fn" "and" "handle" "datatype" "abstype"))
250 : monnier 319 "A `|' corresponds to one of these.")
251 :    
252 :     ;;
253 :     (provide 'sml-defs)

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