]> code.delx.au - gnu-emacs-elpa/commitdiff
* sml-proc.el (inferior-sml-mode-map): Don't inherit from sml-bindings.
authormonnier <>
Thu, 24 Aug 2000 19:35:39 +0000 (19:35 +0000)
committermonnier <>
Thu, 24 Aug 2000 19:35:39 +0000 (19:35 +0000)
Add the binding for C-c C-l explicitly instead.
(sml-run): Look in cwd (but only if the command has slashes).

* sml-mode.el (sml-mode-abbrev-table): Remove (created by
define-derived-mode).
(sml-mode): Setup add-log's current-defun-function.
(sml-indent-line): Never indent to a negative level.
(sml-skip-siblings, sml-beginning-of-defun, sml-max-name-components)
(sml-current-fun-name): New funs and vars for add-log support.
(sml-comment-indent): Simplify.
(sml-def-skeleton): Also create the skeleton as an abbrev.
(skeletons): New for "struct", "sig", "val", "fn" and "fun".
(sml-electric-space): Rewrite to use abbrev's machinery.

* sml-defs.el (sml-mode-map): merge with sml-bindings.
(sml-bindings): Remove.

ChangeLog
NEWS
sml-defs.el
sml-mode.el
sml-move.el
sml-proc.el
testcases.sml

index 23d0382081fbc865aede85f1d1236ed75dbdb631..e6b572302a76e1f339934c7dc98f2eddd0136a07 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,18 +1,37 @@
+2000-08-24  Stefan Monnier  <monnier@cs.yale.edu>
+
+       * sml-proc.el (inferior-sml-mode-map): Don't inherit from sml-bindings.
+       Add the binding for C-c C-l explicitly instead.
+       (sml-run): Look in cwd (but only if the command has slashes).
+
+       * sml-mode.el (sml-mode-abbrev-table): Remove (created by
+       define-derived-mode).
+       (sml-mode): Setup add-log's current-defun-function.
+       (sml-indent-line): Never indent to a negative level.
+       (sml-skip-siblings, sml-beginning-of-defun, sml-max-name-components) 
+       (sml-current-fun-name): New funs and vars for add-log support.
+       (sml-comment-indent): Simplify.
+       (sml-def-skeleton): Also create the skeleton as an abbrev.
+       (skeletons): New for "struct", "sig", "val", "fn" and "fun".
+       (sml-electric-space): Rewrite to use abbrev's machinery.
+
+       * sml-defs.el (sml-mode-map): merge with sml-bindings.
+       (sml-bindings): Remove.
+
 2000-02-22  Stefan Monnier  <monnier@cs.yale.edu>
 
-       * sml-mode.el (sml-find-matching-starter): Use a list of syms instead of a
-         regexp.
+       * sml-mode.el (sml-find-matching-starter): Use syms instead of a RE.
        (sml-indent-default): Use symbol membership rather than a regexp.
-         Also, use `sym-indent' instead of (current-column).  This fixes a problem
-         with a hanging `structure Foo = (struct|let)' (due to `structure' having
-         a sml-indent-rule, as opposed to `fun').  Hopefully it won't introduce
-         other problems.
+       Also, use `sym-indent' instead of (current-column).
+       This fixes a problem with a hanging `structure Foo = (struct|let)'
+       (due to `structure' having a sml-indent-rule, as opposed to `fun').
+       Hopefully it won't introduce other problems.
        (sml-font-lock-keywords): Match vars `val x : int' also.
        (sml-electric-pipe): Update to the new `sml-find-matching-starter' and
-         return a sensible default instead of raising an error in case of
-         unexpected situations.
+       return a sensible default instead of raising an error in case of
+       unexpected situations.
        (sml-indent-line): Ignore errors and keep the cursor where it is.
-       (sml-calculate-indentation, sml-indent-pipe): Use syms instead of regexps.
+       (sml-calculate-indentation, sml-indent-pipe): Use syms instead of REs.
 
        * sml-defs.el (sml-starters-re, sml-pipehead-re): Remove.
 
@@ -27,8 +46,8 @@
 
 2000-02-18  Stefan Monnier  <monnier@cs.yale.edu>
 
-       * sml-util.el (make-temp-dir, make-temp-file, temp-file-dir,
-         delete-temp-dirs): Replaced by the make-temp-file from Emacs-21.
+       * sml-util.el (make-temp-dir, make-temp-file, temp-file-dir)
+       (delete-temp-dirs): Replaced by the make-temp-file from Emacs-21.
        (custom-create-map): add :group arg and allow key to be a list.
        (define-major-mode): Removed (use define-derived-mode instead).
        (sml-builtin-nested-comments-flag): New var.
        (inferior-sml-load-hook): Removed.
        (sml-buffer): Query if the current buffer is not a *sml*.
        (inferior-sml-mode): Use minor-mode-overriding-map-alist to disable
-         compilation-minor-mode's keybindings.
+       compilation-minor-mode's keybindings.
        (run-sml): Turn into an alias for sml-run.
        (sml-run): Query the user for the command.  If prefix is set (or if
-         default value is not null) query for args and host.  Use `split-string'
-         rather than our own function.  Run cmd on another host if requested and
-         pass it an init file if it exists.  Pop to the buffer at the end.
+       default value is not null) query for args and host.
+       Use `split-string' rather than our own function.
+       Run cmd on another host if requested and pass it an init file.
+       Pop to the buffer at the end.
        (sml-args-to-list): Remove.
        (sml-compile): Look for special files (sml-compile-command-alist) in
-         the current dir (and its parents) to choose a default command.  Remember
-         the command for next time in the same buffer.  Make the `cd' explicit in
-         the command so the user can change it.
+       the current dir (and its parents) to choose a default command.
+       Remember the command for next time in the same buffer.
+       Make the `cd' explicit in the command so the user can change it.
        (sml-make-error): Fix for when `endline' is absent.
 
        * sml-mode.el: Pass it through checkdoc.
@@ -76,8 +96,8 @@
        (sml-mode-menu): Use next-error rather than the old sml-next-error.
        (sml-pipehead-re): Remove "of".
 
-       * sml-compat.el (set-keymap-=parents): Make sure it also works when called
-         with a single keymap rather than a list.
+       * sml-compat.el (set-keymap-parents): Make sure it also works when
+       called with a single keymap rather than a list.
        (temporary-file-directory): Add a default definition for XEmacs.
        (make-temp-file): New function.
 
 
        * release: version 3.9.3
 
-       * sml-mode.texi:  somewhat updated the doc.
+       * sml-mode.texi: Somewhat update the doc.
 
 1999-08-09  Stefan Monnier  <monnier@cs.yale.edu>
 
-       * Makefile: updated to the version of pcl-cvs.
+       * Makefile: Update to the version of pcl-cvs.
 
-       * sml-proc.el: eliminated some old unused code.
+       * sml-proc.el: Eliminate some old unused code.
 
-       * sml-defs.el,sml-mode.el,sml-proc.el: added simple customize support.
+       * sml-defs.el,sml-mode.el,sml-proc.el: Add simple customize support.
 
 1999-07-07  Stefan Monnier  <monnier@cs.yale.edu>
 
-       * sml-proc.el (sml-update-cursor): make sure it also works if compile.el
-         is fixed to uses a marker.
+       * sml-proc.el (sml-update-cursor): Make sure it also works if
+       compile.el is fixed to uses a marker.
 
-       * sml-mode.el (sml-indent): fix the `fixindent'.
+       * sml-mode.el (sml-indent): Fix the `fixindent'.
 
 1999-06-22  Stefan Monnier  <monnier@cs.yale.edu>
 
-       * sml-mode-startup.el: fixed to fulfill autoload.el assumptions.
+       * sml-mode-startup.el: Fix to fulfill autoload.el assumptions.
 
 1999-06-21  Stefan Monnier  <monnier@cs.yale.edu>
 
-       * sml-defs.el (sml-bindings): removed bindings for TAB and M-C-\
+       * sml-defs.el (sml-bindings): Remove bindings for TAB and M-C-\.
 
 1999-06-19  Stefan Monnier  <monnier@cs.yale.edu>
 
-       * sml-mode.el (sml-font-lock-keywords): skip type vars in "fun 'a myfn"
-       (sml-calculate-indentation): add a hack to allow the user to manually
-         override the indentation algorithm with a magic comment.
+       * sml-mode.el (sml-font-lock-keywords): Skip type vars in "fun 'a myfn"
+       (sml-calculate-indentation): Add a hack to allow the user to manually
+       override the indentation algorithm with a magic comment.
 
-       * sml-mode-startup.el: update the autoloads automatically.
+       * sml-mode-startup.el: Update the autoloads automatically.
 
 1999-06-19  Stefan Monnier  <monnier@cs.yale.edu>
 
        * release: 3.9.2
 
-       * sml-proc.el (sml-error-regexp-alist): solved the pathological
-         font-locking on long lines.
+       * sml-proc.el (sml-error-regexp-alist): Fix the pathological
+       font-locking on long lines.
 
-       * sml-move.el (sml-forward-sexp): slightly improved.
+       * sml-move.el (sml-forward-sexp): Slightly improved.
 
 1999-06-17  Stefan Monnier  <monnier@cs.yale.edu>
 
        * sml-mode.el (sml-insert-form): Only add a space if needed.
-       (sml-electric-space): new command bound to M-SPC.
+       (sml-electric-space): New command bound to M-SPC.
 
-       * sml-defs.el (sml-close-paren): added a second field that specifies when
-         not to delegate.  Only used for `else'.
+       * sml-defs.el (sml-close-paren): Add a second field that specifies when
+       not to delegate.  Only used for `else'.
 
 1999-06-16  Stefan Monnier  <monnier@cs.yale.edu>
 
-       * sml-move.el (sml-(for|back)ward-sym): distinguishes between
-         operator "=" and syntax for definitions "d=".
+       * sml-move.el (sml-(for|back)ward-sym): Distinguish between
+       operator "=" and syntax for definitions "d=".
 
-       * sml-defs.el (sml-indent-starters, sml-delegate): simplified.
-       (sml-symbol-indent): added outdentation for `fn' and generalized it to
-         also work for `of' and `in' and `end'.
+       * sml-defs.el (sml-indent-starters, sml-delegate): Simplify.
+       (sml-symbol-indent): Add outdentation for `fn' and generalize it to
+       also work for `of' and `in' and `end'.
 
-       * sml-mode.el (sml-nested-if-indent): reintroduced as well as the special
-         casing code for it.
-       (sml-indent-relative): generalize the treatment of `of', `in', `end', ...
-       (sml-electric-pipe): removed the slow behavior and added smarts for the
-         never-used type-variable arguments for function definitions.
+       * sml-mode.el (sml-nested-if-indent): Reintroduce as well as the
+       special casing code for it.
+       (sml-indent-relative): Generalize treatment of `of', `in', `end', ...
+       (sml-electric-pipe): Remove the slow behavior and add smarts for the
+       never-used type-variable arguments for function definitions.
 
 1999-06-15  Stefan Monnier  <monnier@cs.yale.edu>
 
-       * sml-defs.el (sml-mode-menu), sml-mode.el (sml-forms-menu): make the menu
-         dynamically.
+       * sml-defs.el (sml-mode-menu), sml-mode.el (sml-forms-menu):
+       Make the menu dynamically.
 
-       * sml-mode.el (sml-form-<foo>): use skeletons.
-       (sml-calculate-indentation): added `with' indentation.
+       * sml-mode.el (sml-form-<foo>): Use skeletons.
+       (sml-calculate-indentation): Add `with' indentation.
 
 1999-06-14  Stefan Monnier  <monnier@cs.yale.edu>
 
-       * sml-move.el (sml-(for|back)ward-sym): now also return the string if any
-         and take care of the "op" special keyword.
-       (sml-op-prec): setup an alist for the infix operators.
+       * sml-move.el (sml-(for|back)ward-sym): Now also return the string
+       if any and take care of the "op" special keyword.
+       (sml-op-prec): Setup an alist for the infix operators.
 
        * version 3.9.1:  sent to Roland McGrath.
 
 
        * sml-smlnj.el, sml-mosml.el, sml-poly-ml.el: removed.
 
-       * sml-proc.el (...): got rid of sml-next-error by spicing up the interface
-         with compile.el so that intervals can be displayed.  `sml-overlay' is
-         kept (and moved from sml-mode to sml-proc where it belongs) but is
-         made redundant in the case of transient-mark-mode.
+       * sml-proc.el (...): Get rid of sml-next-error by spicing up the
+       interface with compile.el so that intervals can be displayed.
+       `sml-overlay' is kept (and moved from sml-mode to sml-proc where it
+       belongs) but is made redundant in the case of transient-mark-mode.
 
 1999-06-12  Stefan Monnier  <monnier@cs.yale.edu>
 
-       * sml-proc.el (sml-prompt-regexp): more general regexp to catch mosml,
-         smlnj as well as polyml prompts.
-       (sml-update-cursor, sml-send-command, inferior-sml-mode): make it work
-         with compile.el's `next-error'.
-       (sml-temp-threshold): dropped: always use a temp file.
+       * sml-proc.el (sml-prompt-regexp): More general regexp to catch mosml,
+       smlnj as well as polyml prompts.
+       (sml-update-cursor, sml-send-command, inferior-sml-mode):
+       Make it work with compile.el's `next-error'.
+       (sml-temp-threshold): dropped: Always use a temp file.
 
 1999-06-10  Stefan Monnier  <monnier@cs.yale.edu>
 
-       * sml-move.el (sml-op-prec): updated the list of default infix ops based on
-         sml/nj's source files.
+       * sml-move.el (sml-op-prec): Update the list of default infix ops
+       based on sml/nj's source files.
 
 1999-06-08  Stefan Monnier  <monnier@cs.yale.edu>
 
-       * sml-proc.el (sml-run): removed dubious code to take care of a supposedly
-         special case in order not to sent "" when args=nil.
+       * sml-proc.el (sml-run): Remove dubious code to take care of a
+       supposedly special case in order not to send "" when args=nil.
 
 1999-06-07  Stefan Monnier  <monnier@cs.yale.edu>
 
-       * sml-mode.el (sml-font-lock-syntactic-keywords): added syntactic
-         fontification for the '   \"' case (exhibited by lexgen.sml).
+       * sml-mode.el (sml-font-lock-syntactic-keywords): Add syntactic
+       fontification for the '   \"' case (exhibited by lexgen.sml).
 
 1999-06-07  Stefan Monnier  <monnier@cs.yale.edu>
 
-       * ALL: the new indentation begins to work.  v3_9_0
+       * ALL: The new indentation begins to work.  v3_9_0
 
 1999-05-29  Stefan Monnier  <monnier@cs.yale.edu>
 
        * sml-defs.el (sml-mode-syntax-table): added ~ of prefix-syntax.
 
-       * sml-mode.el (sml-find-match-indent): (nilp sml-type-of-indent) is only
-         applied if the `let' is alone at the end of the line.
-       (sml-type-of-indent): default changed to `nil'.
+       * sml-mode.el (sml-find-match-indent): (nilp sml-type-of-indent) is
+       only applied if the `let' is alone at the end of the line.
+       (sml-type-of-indent): Default changed to `nil'.
 
 1999-05-28  Stefan Monnier  <monnier@cs.yale.edu>
 
-       * sml-mode.el (sml-font-lock-keywords): changed _ and ' back to word
-         syntax for font-locking.
+       * sml-mode.el (sml-font-lock-keywords): Change _ and ' back to word
+       syntax for font-locking.
 
 1999-05-27  Stefan Monnier  <monnier@cs.yale.edu>
 
-       * sml-mode.el (sml-font-lock-syntactic-keywords): finally got the
-         matching of let...end working.
-         (sml-electric-pipe): take a fun sexp (symbol) rather than a fun word.
+       * sml-mode.el (sml-font-lock-syntactic-keywords): Finally got the
+       matching of let...end working.
+       (sml-electric-pipe): Take a fun sexp (symbol) rather than a fun word.
 
 1998-10-26  Stefan Monnier  <monnier@cs.yale.edu>
 
-       * sml-mode.el (sml-font-lock-syntactic-keywords): added syntactic-keywords
-         to support nested comments.
+       * sml-mode.el (sml-font-lock-syntactic-keywords):
+       Add syntactic-keywords to support nested comments.
 
diff --git a/NEWS b/NEWS
index c88d691c9ea4829289df8d0fd639a1af1e1ee477..02eded6750d856ba2c0dbac175198f6043f7ba18 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,11 @@
 Changes since 3.9.3:
 
+* New add-log support.
+
+* sml-bindings has disappeared.
+
+* The code skeletons are now abbrevs as well.
+
 * A new *sml* process is sent the content of sml-config-file (~/.sml-proc.sml)
   if it exists.
 
@@ -7,7 +13,7 @@ Changes since 3.9.3:
   with `cd "path";' and it will be replaced by OS.FileSys.chDir.
 
 * run-sml now pops up the new buffer.  It can also run the command on another
-  machine.  And it always prompts for the command name.  Use aprefix
+  machine.  And it always prompts for the command name.  Use a prefix
   argument if you want to give args or to specify a host on which
   to run the command.
 
@@ -16,7 +22,7 @@ Changes since 3.9.3:
 
 * Added a trivial CM major-mode.
 
-* sml-load-hook has disappeared.
+* sml-load-hook has disappeared as has inferior-sml-load-hook.
 
 * sml-mode-startup.el is now automatically generated and you're supposed to
   `load' it from .emacs or siate-start.el.
index 4b060dfacbd2c700ddf16e33a0865c6cb904d0b3..2c6d6c76ca9b2f9b6276f6b5bf6704634a0b6474 100644 (file)
@@ -36,7 +36,7 @@
 ;;; Internal defines
 ;;; 
 
-(defmap sml-bindings
+(defmap sml-mode-map
   ;; smarter cursor movement
   '((forward-sexp      . sml-user-forward-sexp)
     (backward-sexp     . sml-user-backward-sexp)
     ("\C-c\C-m"        . sml-insert-form)
     ("\C-c\C-i"        . sml-mode-info)
     ("\M-|"    . sml-electric-pipe)
-    ("\M-\ "   . sml-electric-pipe)
+    ("\M-\ "   . sml-electric-space)
     ("\;"      . sml-electric-semi)
     ("\M-\t"   . sml-back-to-outer-indent)
-    ;;("\C-\M-\\"      . sml-indent-region)
-    ;;("\t"    . sml-indent-line)      ; ...except this one
     ;; Process commands added to sml-mode-map -- these should autoload
     ("\C-c\C-l"        . sml-load-file)
-    ;;("\C-c`" . sml-next-error)
-    )
-  "Generic bindings used in `sml-mode' and `inferior-sml-mode'."
-  :group 'sml)
-
-(defmap sml-mode-map
-  '(("\C-c\C-c" . sml-compile)
+    ("\C-c\C-c" . sml-compile)
     ("\C-c\C-s" . switch-to-sml)
     ("\C-c\C-r" . sml-send-region)
     ("\C-c\C-b" . sml-send-buffer)
     ([(meta shift down-mouse-1)] . sml-drag-region))
   "The keymap used in `sml-mode'."
-  :inherit sml-bindings
+  ;; :inherit sml-bindings
   :group 'sml)
 
 (defsyntax sml-mode-syntax-table
@@ -75,8 +67,7 @@
     ;; `!' is not really a prefix-char, oh well!
     ("~#!" . "'")
     ("%&$+-/:<=>?@`^|"  . "."))
-  "The syntax table used in sml-mode.")
-
+  "The syntax table used in `sml-mode'.")
 
 
 (easy-menu-define sml-mode-menu sml-mode-map "Menu used in sml-mode."
@@ -94,9 +85,9 @@
      ;;["goto next error"              sml-next-error  (featurep 'sml-proc)]
      ["goto next error"                next-error      (featurep 'sml-proc)]
      ["---" nil nil]
-     ["Standard ML of New Jersey" sml-smlnj    (fboundp 'sml-smlnj)]
-     ["Poly/ML"                        sml-poly-ml     (fboundp 'sml-poly-ml)]
-     ["Moscow ML"              sml-mosml       (fboundp 'sml-mosml)]
+     ;; ["Standard ML of New Jersey" sml-smlnj (fboundp 'sml-smlnj)]
+     ;; ["Poly/ML"                     sml-poly-ml     (fboundp 'sml-poly-ml)]
+     ;; ["Moscow ML"           sml-mosml       (fboundp 'sml-mosml)]
      ["Help for Inferior ML"   (describe-function 'inferior-sml-mode) :active (featurep 'sml-proc)])
     ["electric pipe"     sml-electric-pipe t]
     ["insert SML form"   sml-insert-form t]
index 68ea40b25aef3f769ae419cca3e93fef927064ce..aa68af8758015c7a7fded6517b1013f61e6baeb0 100644 (file)
@@ -142,8 +142,6 @@ set-variable command.")
   "*Run upon entering `sml-mode'.
 This is a good place to put your preferred key bindings.")
 
-(defvar sml-mode-abbrev-table nil "*Abbrev table for `sml-mode'.")
-
 ;;; CODE FOR SML-MODE
 
 (defun sml-mode-info ()
@@ -275,6 +273,10 @@ This mode runs `sml-mode-hook' just before exiting.
 \\{sml-mode-map}"
   (set (make-local-variable 'font-lock-defaults) sml-font-lock-defaults)
   (set (make-local-variable 'outline-regexp) sml-outline-regexp)
+  (set (make-local-variable 'add-log-current-defun-function)
+       'sml-current-fun-name)
+  ;; forward-sexp-function is an experimental variable in my hacked Emacs.
+  (set (make-local-variable 'forward-sexp-function) 'sml-user-forward-sexp)
   (sml-mode-variables))
 
 (defun sml-mode-variables ()
@@ -379,7 +381,7 @@ If anyone has a good algorithm for this..."
   "Indent current line of ML code."
   (interactive)
   (let ((savep (> (current-column) (current-indentation)))
-       (indent (or (ignore-errors (sml-calculate-indentation)) 0)))
+       (indent (max (or (ignore-errors (sml-calculate-indentation)) 0) 0)))
     (if savep
        (save-excursion (indent-line-to indent))
       (indent-line-to indent))))
@@ -617,13 +619,50 @@ Optional argument STYLE is currently ignored"
                 (not (or (member sym syms) (bobp)))))
       (unless (bobp) sym))))
 
+(defun sml-skip-siblings ()
+  (while (and (not (bobp)) (sml-backward-arg))
+    (sml-find-matching-starter sml-starters-syms))
+  (when (looking-at "in\\>\\|local\\>")
+    ;;skip over `local...in' and continue
+    (forward-word 1)
+    (sml-backward-sexp nil)
+    (sml-skip-siblings)))
+
+(defun sml-beginning-of-defun ()
+  (let ((sym (sml-find-matching-starter sml-starters-syms)))
+    (if (member sym '("fun" "functor" "signature" "structure"
+                     "abstraction" "datatype" "abstype"))
+       (save-excursion (sml-forward-sym) (sml-forward-spaces)
+                       (sml-forward-sym))
+      ;; We're inside a "non function declaration": let's skip all other
+      ;; declarations that we find at the same level and try again.
+      (sml-skip-siblings)
+      ;; Obviously, let's not try again if we're at bobp.
+      (unless (bobp) (sml-beginning-of-defun)))))
+
+(defcustom sml-max-name-components 3
+  "Maximum number of components to use for the current function name."
+  :group 'sml
+  :type 'integer)
+
+(defun sml-current-fun-name ()
+  (save-excursion
+    (let ((count sml-max-name-components)
+         fullname name)
+      (end-of-line)
+      (while (and (> count 0)
+                 (setq name (sml-beginning-of-defun)))
+       (decf count)
+       (setq fullname (if fullname (concat name "." fullname) name))
+       ;; Skip all other declarations that we find at the same level.
+       (sml-skip-siblings))
+      fullname)))
+    
+
 (defun sml-comment-indent ()
   (if (looking-at "^(\\*")              ; Existing comment at beginning
       0                                 ; of line stays there.
-    (save-excursion
-      (skip-chars-backward " \t")
-      (max (1+ (current-column))        ; Else indent at comment column
-           comment-column))))           ; except leave at least one space.
+    comment-column))
 
 ;;; INSERTING PROFORMAS (COMMON SML-FORMS)
 
@@ -644,6 +683,7 @@ signature, structure, and functor by default.")
   (let ((fsym (intern (concat "sml-form-" name))))
     `(progn
        (add-to-list 'sml-forms-alist ',(cons name fsym))
+       (define-abbrev sml-mode-abbrev-table ,name "" ',fsym)
        (define-skeleton ,fsym
         ,(format "SML-mode skeleton for `%s..' expressions" name)
         ,interactor
@@ -672,14 +712,31 @@ signature, structure, and functor by default.")
 (sml-def-skeleton "functor" "Functor name: "
   str " () : =\nstruct" > "\n" > _ "\nend" >)
 
-(sml-def-skeleton "datatype" "Datatype name and type parameters: "
+(sml-def-skeleton "datatype" "Datatype name and type params: "
   str " =" \n)
 
-(sml-def-skeleton "abstype" "Abstype name and type parameters: "
+(sml-def-skeleton "abstype" "Abstype name and type params: "
   str " =" \n _ "\nwith" > "\nend" >)
 
 ;;
 
+(sml-def-skeleton "struct" nil
+  _ "\nend" >)
+
+(sml-def-skeleton "sig" nil
+  _ "\nend" >)
+
+(sml-def-skeleton "val" nil
+  _ " = " >)
+
+(sml-def-skeleton "fn" nil
+  _ " =>" >)
+
+(sml-def-skeleton "fun" nil
+  _ " =" >)
+
+;;
+
 (defun sml-forms-menu (menu)
   (easy-menu-filter-return
    (easy-menu-create-menu "Forms"
@@ -696,12 +753,11 @@ signature, structure, and functor by default.")
 If the point directly precedes a symbol for which an SML form exists,
 the corresponding form is inserted."
   (interactive)
-  (let* ((point (point))
-        (sym (sml-backward-sym)))
-    (if (not (and sym (assoc sym sml-forms-alist)))
-       (progn (goto-char point) (insert " "))
-      (delete-region (point) point)
-      (sml-insert-form sym nil))))
+  (let ((abbrev-mode (not abbrev-mode))
+       (last-command-char ?\ )
+       ;; Bind `this-command' to fool skeleton's special abbrev handling.
+       (this-command 'self-insert-command))
+    (call-interactively 'self-insert-command)))
 
 (defun sml-insert-form (name newline)
   "Interactive short-cut to insert the NAME common ML form.
index 3f30465409890bafd9fceed73f2de3f4d6c60ba3..9ff27e6457a4b56e68df9da65841b5cb2a61e0b9 100644 (file)
@@ -126,6 +126,7 @@ This assumes that we are `looking-at' the OP."
 (defun sml-find-match-forward (this match)
   "Only works for word matches."
   (let ((level 1)
+       (forward-sexp-function nil)
        (either (concat this "\\|" match)))
     (while (> level 0)
       (forward-sexp 1)
@@ -140,6 +141,7 @@ This assumes that we are `looking-at' the OP."
 
 (defun sml-find-match-backward (this match)
   (let ((level 1)
+       (forward-sexp-function nil)
        (either (concat this "\\|" match)))
     (while (> level 0)
       (backward-sexp 1)
@@ -161,7 +163,7 @@ This assumes that we are `looking-at' the OP."
     `(let ((,pt-sym (point)))
        ,@body
        (when (/= (point) ,pt-sym)
-        (buffer-substring (point) ,pt-sym)))))
+        (buffer-substring-no-properties (point) ,pt-sym)))))
 (def-edebug-spec sml-move-read t)
 
 (defun sml-poly-equal-p ()
@@ -174,8 +176,8 @@ This assumes that we are `looking-at' the OP."
      (sml-point-after (re-search-backward "\\<case\\>" nil 'move))))
 
 (defun sml-forward-sym-1 ()
-  (or (/= 0 (skip-syntax-forward ".'"))
-      (/= 0 (skip-syntax-forward "'w_"))))
+  (or (/= 0 (skip-syntax-forward "'w_"))
+      (/= 0 (skip-syntax-forward ".'"))))
 (defun sml-forward-sym ()
   (let ((sym (sml-move-read (sml-forward-sym-1))))
     (cond
@@ -223,8 +225,8 @@ Returns T if the move indeed moved through one sexp and NIL if not."
       (cond
        ((not op)
        (let ((point (point)))
-         (ignore-errors (backward-sexp 1))
-         (if (/= point (point)) t (backward-char 1) nil)))
+         (ignore-errors (let ((forward-sexp-function nil)) (backward-sexp 1)))
+         (if (/= point (point)) t (ignore-errors (backward-char 1)) nil)))
        ;; stop as soon as precedence is smaller than `prec'
        ((and prec op-prec (>= prec op-prec)) nil)
        ;; special rules for nested constructs like if..then..else
@@ -257,7 +259,7 @@ Returns T if the move indeed moved through one sexp and NIL if not."
       (cond
        ((not op)
        (let ((point (point)))
-         (ignore-errors (forward-sexp 1))
+         (ignore-errors (let ((forward-sexp-function nil)) (forward-sexp 1)))
          (if (/= point (point)) t (forward-char 1) nil)))
        ;; stop as soon as precedence is smaller than `prec'
        ((and prec op-prec (>= prec op-prec)) nil)
@@ -265,7 +267,7 @@ Returns T if the move indeed moved through one sexp and NIL if not."
        ((and (or (not prec) (and prec op-prec))
             (setq match (cdr (assoc op sml-open-paren))))
        (sml-find-match-forward (first match) (second match)))
-       ;; don't back over open-parens
+       ;; don't forw over close-parens
        ((assoc op sml-close-paren) nil)
        ;; infix ops precedence
        ((and prec op-prec) (< prec op-prec))
index 42bb01e160df4d16d441d1deb728bdf93fa0a8c2..5f3b666b58009d257d8de388638b0f16e628b38f 100644 (file)
@@ -256,9 +256,10 @@ See `compilation-error-regexp-alist' for a description of the format.")
 
 (defmap inferior-sml-mode-map
   '(("\C-c\C-s"        . run-sml)
+    ("\C-c\C-l"        . sml-load-file)
     ("\t"      . comint-dynamic-complete))
   "Keymap for inferior-sml mode"
-  :inherit (list sml-bindings comint-mode-map)
+  :inherit comint-mode-map
   :group 'sml-proc)
 
 
@@ -348,11 +349,11 @@ TAB file name completion, as in shell-mode, etc.."
   (setq comint-prompt-regexp sml-prompt-regexp)
   (sml-mode-variables)
 
+  (set (make-local-variable 'font-lock-defaults)
+       inferior-sml-font-lock-defaults)
   ;; For sequencing through error messages:
   (set (make-local-variable 'sml-error-cursor) (point-max-marker))
   (set-marker-insertion-type sml-error-cursor nil)
-  (set (make-local-variable 'font-lock-defaults)
-       inferior-sml-font-lock-defaults)
 
   ;; compilation support (used for next-error)
   (set (make-local-variable 'compilation-error-regexp-alist)
@@ -411,7 +412,12 @@ on which to run CMD using `remote-shell-program'.
       (setq args (list* host "cd" default-directory ";" cmd args))
       (setq cmd remote-shell-program))
     ;; go for it
-    (setq sml-buffer (apply 'make-comint pname cmd file args))
+    (let ((exec-path (if (file-name-directory cmd)
+                        ;; If the command has slashes, make sure we
+                        ;; first look relative to the current directory.
+                        ;; Emacs-21 does it for us, but not Emacs-20.
+                        (cons default-directory exec-path) exec-path)))
+      (setq sml-buffer (apply 'make-comint pname cmd file args)))
 
     (pop-to-buffer sml-buffer)
     ;;(message (format "Starting \"%s\" in background." pname))
index 23ace7b54b53828dc436246273e30bb2b750c2fa..8d7e8595e8a62f985ee7fbd9c4005b35f5f647d4 100644 (file)
@@ -1,6 +1,23 @@
 (* copyright 1999 YALE FLINT project *)
 (* monnier@cs.yale.edu *)
 
+(let val a = 1 val b = 2
+     val c = 3
+ in 1
+ end)
+
+(x := 1;
+ case x of
+     FOO => 1
+   | BAR => 2;
+ case x of
+     FOO => 1
+   | BAR =>
+     (case y of
+         FAR => 2
+       | FRA => 3);
+ hello)
+
 let datatype foobar
       = FooB of int
       | FooA of bool * int
@@ -39,7 +56,7 @@ in if a then
    else
        c
 end
-    
+
 let
 in case a of
     (* Do I really want that ? *)