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

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

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

Legend:
Removed from v.319  
changed lines
  Added in v.535

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