+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.
# 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
;;; 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,
;;; 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,
;; regexps
;;
-(defun sml-syms-re (&rest syms)
- (concat "\\<" (regexp-opt (flatten syms) t) "\\>"))
+(defun sml-syms-re (syms)
+ (concat "\\<" (regexp-opt syms t) "\\>"))
;;
"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
"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
"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
;; 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
;; 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
;; 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)")
,@(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)
(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))
@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,
@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
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
;;; 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,
;; 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
(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.
(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) '(?/ . ?\"))
;;; 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)
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