]> code.delx.au - gnu-emacs-elpa/commitdiff
(no commit message)
authormonnier <>
Wed, 31 Oct 2007 03:07:04 +0000 (03:07 +0000)
committermonnier <>
Wed, 31 Oct 2007 03:07:04 +0000 (03:07 +0000)
ChangeLog
Makefile
sml-compat.el
sml-defs.el
sml-mode.el
sml-mode.texi
sml-move.el
sml-proc.el
sml-util.el

index 672679a374bc390a86b45086f7555ede59ba833d..c836bc40d2401552cab9fe4d5db59a6dc01480ec 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2007-10-31  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * sml-util.el (defmap, defsyntax): Avoid defconst.
+       (flatten): Remove.
+
+       * sml-mode.el (sml-calculate-indentation): Avoid previous-line.
+       (sml-keywords-regexp): Avoid the need for `flatten'.
+       (sml-defuse-jump-to-def): Fix typo.
+
+       * sml-defs.el (sml-syms-re): Don't use `flatten'.
+       (sml-sexp-head-symbols-re, sml-starters-indent-after)
+       (sml-non-nested-of-starter-re): Avoid the need for `flatten'.
+
+       * sml-proc.el (inferior-sml-next-error-hook): New fun.
+       (inferior-sml-mode): Use it.
+
 2007-06-29  Stefan Monnier  <monnier@iro.umontreal.ca>
 
        * sml-mode.el (sml-mlton-error-regexp-alist): New var.
index 70b3c722fc9b41816c3da2598a5a26aac6946b60..7327f52432c7619171f7571f208c010b940a0e3a 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,10 +1,10 @@
 # Makefile for emacs-lisp package
 
-# Copyright (C) 1998, 1999, 2004  Stefan Monnier <monnier@gnu.org>
+# Copyright (C) 1998, 1999, 2004, 2007  Stefan Monnier <monnier@gnu.org>
 
 # This file is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by the
-# Free Software Foundation; either version 2, or (at your option) any
+# Free Software Foundation; either version 3, or (at your option) any
 # later version.
 
 # This file is distributed in the hope that it will be useful, but WITHOUT
index 7557a32994129ee97145d85d778e2ba606de66f6..c7453fe2895fa8696e921a5428fcdc6d5b73fb7e 100644 (file)
@@ -1,10 +1,10 @@
 ;;; sml-compat.el --- Compatibility functions for Emacs variants for sml-mode
 
-;; Copyright (C) 1999, 2000, 2004  Stefan Monnier <monnier@gnu.org>
+;; Copyright (C) 1999, 2000, 2004, 2007  Stefan Monnier <monnier@gnu.org>
 ;;
 ;; This program is free software; you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2 of the License, or
+;; the Free Software Foundation; either version 3 of the License, or
 ;; (at your option) any later version.
 ;;
 ;; This program is distributed in the hope that it will be useful,
index b685b4133d46bb1c9a3a5b6dc47838a021cec390..38ec9962d534c4d616a370f63b571ff847566253 100644 (file)
@@ -1,10 +1,10 @@
 ;;; sml-defs.el --- Various definitions for sml-mode
 
-;; Copyright (C) 1999,2000,2003,2005  Stefan Monnier <monnier@cs.yale.edu>
+;; Copyright (C) 1999,2000,2003,2005,2007  Stefan Monnier <monnier@gnu.org>
 ;;
 ;; This program is free software; you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2 of the License, or
+;; the Free Software Foundation; either version 3 of the License, or
 ;; (at your option) any later version.
 ;;
 ;; This program is distributed in the hope that it will be useful,
@@ -125,8 +125,8 @@ notion of \"the end of an outline\".")
 ;; regexps
 ;;
 
-(defun sml-syms-re (&rest syms)
-  (concat "\\<" (regexp-opt (flatten syms) t) "\\>"))
+(defun sml-syms-re (syms)
+  (concat "\\<" (regexp-opt syms t) "\\>"))
 
 ;;
 
@@ -143,23 +143,23 @@ notion of \"the end of an outline\".")
   "Symbols matching the `end' symbol.")
 
 ;; (defconst sml-user-begin-symbols-re
-;;   (sml-syms-re "let" "abstype" "local" "struct" "sig" "in" "with")
+;;   (sml-syms-re '("let" "abstype" "local" "struct" "sig" "in" "with"))
 ;;   "Symbols matching (loosely) the `end' symbol.")
 
 (defconst sml-sexp-head-symbols-re
-  (sml-syms-re "let" "abstype" "local" "struct" "sig" "in" "with"
-              "if" "then" "else" "case" "of" "fn" "fun" "val" "and"
-              "datatype" "type" "exception" "open" "infix" "infixr" "nonfix"
-              sml-module-head-syms
-              "handle" "raise")
+  (sml-syms-re `("let" "abstype" "local" "struct" "sig" "in" "with"
+                 "if" "then" "else" "case" "of" "fn" "fun" "val" "and"
+                 "datatype" "type" "exception" "open" "infix" "infixr" "nonfix"
+                 ,@sml-module-head-syms
+                 "handle" "raise"))
   "Symbols starting an sexp.")
 
 ;; (defconst sml-not-arg-start-re
-;;   (sml-syms-re "in" "of" "end" "andalso")
+;;   (sml-syms-re '("in" "of" "end" "andalso"))
 ;;   "Symbols that can't be found at the head of an arg.")
 
 ;; (defconst sml-not-arg-re
-;;   (sml-syms-re "in" "of" "end" "andalso")
+;;   (sml-syms-re '("in" "of" "end" "andalso"))
 ;;   "Symbols that should not be confused with an arg.")
 
 (defconst sml-=-starter-syms
@@ -185,7 +185,7 @@ notion of \"the end of an outline\".")
        "do" "with" "withtype")))))
 
 (defconst sml-starters-indent-after
-  (sml-syms-re "let" "local" "struct" "in" "sig" "with")
+  (sml-syms-re '("let" "local" "struct" "in" "sig" "with"))
   "Indent after these.")
 
 (defconst sml-delegate
@@ -230,7 +230,7 @@ for all symbols and in all lines starting with the given symbol."
   "Regexp of compound symbols (pairs of symbols to be considered as one).")
 
 (defconst sml-non-nested-of-starter-re
-  (sml-syms-re "datatype" "abstype" "exception")
+  (sml-syms-re '("datatype" "abstype" "exception"))
   "Symbols that can introduce an `of' that shouldn't behave like a paren.")
 
 (defconst sml-starters-syms
index df5d814ab62cb392288956a03947c9faaaced4b7..43a642bc3145b75fe61fa0c30275a4191ba472be 100644 (file)
@@ -21,7 +21,7 @@
 
 ;; This program is free software; you can redistribute it and/or
 ;; modify it under the terms of the GNU General Public License as
-;; published by the Free Software Foundation; either version 2, or (at
+;; published by the Free Software Foundation; either version 3, or (at
 ;; your option) any later version.
 
 ;; This program is distributed in the hope that it will be useful, but
@@ -159,13 +159,13 @@ Full documentation will be available after autoloading the function."))
 ;; font-lock setup
 
 (defconst sml-keywords-regexp
-  (sml-syms-re "abstraction" "abstype" "and" "andalso" "as" "before" "case"
-              "datatype" "else" "end" "eqtype" "exception" "do" "fn"
-              "fun" "functor" "handle" "if" "in" "include" "infix"
-              "infixr" "let" "local" "nonfix" "of" "op" "open" "orelse"
-              "overload" "raise" "rec" "sharing" "sig" "signature"
-              "struct" "structure" "then" "type" "val" "where" "while"
-              "with" "withtype" "o")
+  (sml-syms-re '("abstraction" "abstype" "and" "andalso" "as" "before" "case"
+                 "datatype" "else" "end" "eqtype" "exception" "do" "fn"
+                 "fun" "functor" "handle" "if" "in" "include" "infix"
+                 "infixr" "let" "local" "nonfix" "of" "op" "open" "orelse"
+                 "overload" "raise" "rec" "sharing" "sig" "signature"
+                 "struct" "structure" "then" "type" "val" "where" "while"
+                 "with" "withtype" "o"))
   "A regexp that matches any and all keywords of SML.")
 
 (defconst sml-tyvarseq-re
@@ -559,14 +559,13 @@ If anyone has a good algorithm for this..."
 
        ;; Continued string ? (Added 890113 lbn)
        (and (looking-at "\\\\")
-            (save-excursion
-              (if (save-excursion (previous-line 1)
-                                  (beginning-of-line)
-                                  (looking-at "[\t ]*\\\\"))
-                  (progn (previous-line 1) (current-indentation))
-                (if (re-search-backward "[^\\\\]\"" nil t)
-                    (1+ (current-column))
-                  0))))
+             (or (save-excursion (forward-line -1)
+                                 (if (looking-at "[\t ]*\\\\")
+                                     (current-indentation)))
+                 (save-excursion
+                   (if (re-search-backward "[^\\\\]\"" nil t)
+                       (1+ (current-column))
+                     0))))
 
        ;; Closing parens.  Could be handled below with `sml-indent-relative'?
        (and (looking-at "\\s)")
@@ -1001,7 +1000,7 @@ See also `edit-kbd-macro' which is bound to \\[edit-kbd-macro]."
      ,@(if (fboundp 'compilation-fake-loc) '((1))))))
 
 (eval-after-load "compile"
-  '(dolist ((x sml-mlton-error-regexp-alist))
+  '(dolist (x sml-mlton-error-regexp-alist)
      (add-to-list 'compilation-error-regexp-alist x)))
 
 (defun sml-mlton-typecheck (mainfile)
@@ -1066,7 +1065,7 @@ See also `edit-kbd-macro' which is bound to \\[edit-kbd-macro]."
       (with-current-buffer (find-file-noselect (sml-defuse-file))
         (goto-char (point-min))
         (unless (re-search-forward
-                 (format sml-defuse-use-format
+                 (format sml-defuse-use-regexp-format
                          (concat "\\(?:"
                                  ;; May be an absolute file name.
                                  (regexp-quote (nth 3 symdata))
index cf5093c67911d98fdb9af12a3a7b7db4ffd096c5..b78dee4a40d7ade63e3307f29035d6a4a6caffc4 100644 (file)
@@ -9,7 +9,7 @@
 
 @comment sml-mode is free software; you can redistribute it and/or modify
 @comment it under the terms of the GNU General Public License as published by
-@comment the Free Software Foundation; either version 2 of the License,
+@comment the Free Software Foundation; either version 3 of the License,
 @comment or (at your option) any later version.
 
 @comment sml-mode is distributed in the hope that it will be useful,
@@ -46,7 +46,7 @@ Copyright @copyright{} (Anon)
 @sp 1
 @noindent
 GNU General Public License as published by the Free Software Foundation;
-either version 2, or (at your option) any later version.
+either version 3, or (at your option) any later version.
 
 @sp 1
 @noindent
@@ -134,7 +134,7 @@ made available under the liberal terms of the GNU General Public
 License.
 
 GNU General Public License as published by the Free Software Foundation;
-either version 2, or (at your option) any later version.
+either version 3, or (at your option) any later version.
 
 SML mode is distributed in the hope that it will be useful, but
 WITHOUT ANY WARRANTY; without even the implied warranty of
index f6db042b6badfdfcfee9798e14678f7d00dc92ca..8813dc098922fe1bf19d68a2973298cbad3b9919 100644 (file)
@@ -1,10 +1,10 @@
 ;;; sml-move.el --- Buffer navigation functions for sml-mode
 
-;; Copyright (C) 1999, 2000, 2004  Stefan Monnier <monnier@gnu.org>
+;; Copyright (C) 1999, 2000, 2004, 2007  Stefan Monnier <monnier@gnu.org>
 ;;
 ;; This program is free software; you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2 of the License, or
+;; the Free Software Foundation; either version 3 of the License, or
 ;; (at your option) any later version.
 ;;
 ;; This program is distributed in the hope that it will be useful,
index cbd2ab9896c81bf74a2c76ec36dbed85bb2a01f9..f6c55fce5f47d7ad734c8d50a5d88d9a83bfe51d 100644 (file)
@@ -14,7 +14,7 @@
 
 ;; This program is free software; you can redistribute it and/or
 ;; modify it under the terms of the GNU General Public License as
-;; published by the Free Software Foundation; either version 2, or (at
+;; published by the Free Software Foundation; either version 3, or (at
 ;; your option) any later version.
 
 ;; This program is distributed in the hope that it will be useful, but
@@ -308,6 +308,32 @@ If prefix argument ECHO is set, then it only reports on the current state."
       (progn (call-interactively 'run-sml)
             (get-buffer-process (current-buffer)))))
 
+(defun inferior-sml-next-error-hook ()
+  ;; Try to recognize SML/NJ type error message and to highlight finely the
+  ;; difference between the two types (in case they're large, it's not
+  ;; always obvious to spot it).
+  (save-current-buffer
+    (when (and (derived-mode-p 'sml-mode 'inferior-sml-mode)
+               (boundp 'next-error-last-buffer)
+               (bufferp next-error-last-buffer)
+               (set-buffer next-error-last-buffer)
+               (derived-mode-p 'inferior-sml-mode)
+               ;; The position of `point' is not guaranteed :-(
+               (looking-at ".*\n  operator domain: "))
+      (ignore-errors (require 'smerge-mode))
+      (if (not (fboundp 'smerge-refine-subst))
+          (remove-hook 'next-error-hook 'inferior-sml-next-error-hook)
+        (save-excursion
+          (let ((b1 (match-end 0))
+                e1 b2 e2)
+            (when (re-search-forward "\n  in expression:\n" nil t)
+              (setq e2 (match-beginning 0))
+              (when (re-search-backward "\n  operand:         " b1 t)
+                (setq e1 (match-beginning 0))
+                (setq b2 (match-end 0))
+                (smerge-refine-subst b1 e1 b2 e2
+                                     '((face . smerge-refined-change)))))))))))
+
 (define-derived-mode inferior-sml-mode comint-mode "Inferior-SML"
   "Major mode for interacting with an inferior ML process.
 
@@ -355,6 +381,9 @@ TAB file name completion, as in shell-mode, etc.."
   (setq comint-prompt-regexp sml-prompt-regexp)
   (sml-mode-variables)
 
+  ;; We have to install it globally, 'cause it's run in the *source* buffer :-(
+  (add-hook 'next-error-hook 'inferior-sml-next-error-hook)
+
   ;; Make TAB add a " rather than a space at the end of a file name.
   (set (make-local-variable 'comint-completion-addsuffix) '(?/ . ?\"))
 
index 554017886d4f9752da74a0ad20f2ac62e5776737..053d96bf322ead09864d52a20453cf4fbadf7f63 100644 (file)
@@ -1,10 +1,10 @@
 ;;; sml-util.el --- Utility functions for sml-mode
 
-;; Copyright (C) 1999-2000  Stefan Monnier <monnier@cs.yale.edu>
+;; Copyright (C) 1999-2000, 2007  Stefan Monnier <monnier@cs.yale.edu>
 ;;
 ;; This program is free software; you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2 of the License, or
+;; the Free Software Foundation; either version 3 of the License, or
 ;; (at your option) any later version.
 ;;
 ;; This program is distributed in the hope that it will be useful,
 (require 'cl)                          ;for `reduce'
 (require 'sml-compat)
 
-;;
-
-(defun flatten (ls &optional acc)
-  (if (null ls) acc
-    (let ((rest (flatten (cdr ls) acc))
-         (head (car ls)))
-      (if (listp head)
-         (flatten head rest)
-       (cons head rest)))))
-
 (defun sml-preproc-alist (al)
   "Expand an alist AL where keys can be lists of keys into a normal one."
   (reduce (lambda (x al)
@@ -83,7 +73,7 @@
     m))
 
 (defmacro defmap (m bs doc &rest args)
-  `(defconst ,m
+  `(defvar ,m
      (custom-create-map (if (boundp ',m) ,m) ,bs ,(cons 'list args))
      ,doc))
 
     st))
 
 (defmacro defsyntax (st css doc &rest args)
-  `(defconst ,st (custom-create-syntax ,css ,(cons 'list args)) ,doc))
+  `(defvar ,st (custom-create-syntax ,css ,(cons 'list args)) ,doc))
 
 ;;;; 
 ;;;; Compatibility info