* sml-proc.el (inferior-sml-mode-map): Don't use defmap.
* sml-move.el (sml-internal-syntax-table): Don't use defsyntax.
* sml-mode.el (sml-syntax-prop-table): Don't use defsyntax.
(sml-electric-space): `last-command-char' -> `last-command-event'.
(sml-defuse-jump-to-def): Don't use goto-line from Elisp.
* sml-defs.el (sml-mode-map): Don't use defmap.
(sml-mode-syntax-table): Don't use defsyntax.
(sml-preproc-alist, sml-builtin-nested-comments-flag):
Move from sml-util.el.
* sml-compat.el, sml-utils.el: Remove.
* makefile.pkg (ELFILES): Update.
+2012-04-11 Stefan Monnier <monnier@iro.umontreal.ca>
+
+ Get rid of ancient compatibility and small utility file.
+ * sml-proc.el (inferior-sml-mode-map): Don't use defmap.
+ * sml-move.el (sml-internal-syntax-table): Don't use defsyntax.
+ * sml-mode.el (sml-syntax-prop-table): Don't use defsyntax.
+ (sml-electric-space): `last-command-char' -> `last-command-event'.
+ (sml-defuse-jump-to-def): Don't use goto-line from Elisp.
+ * sml-defs.el (sml-mode-map): Don't use defmap.
+ (sml-mode-syntax-table): Don't use defsyntax.
+ (sml-preproc-alist, sml-builtin-nested-comments-flag):
+ Move from sml-util.el.
+ * sml-compat.el, sml-utils.el: Remove.
+ * makefile.pkg (ELFILES): Update.
+
2012-04-11 Stefan Monnier <monnier@iro.umontreal.ca>
Add SMIE support.
* .bzrignore: New file.
* makefile.pkg (test): Use sml-mode-startup.
+
* sml-mode.el (sml-use-smie): New config var.
(sml-smie-grammar, sml-indent-separator-outdent): New vars.
(sml-smie-rules, sml-smie-definitional-equal-p)
PACKAGE = sml-mode
-ELFILES = sml-compat.el sml-util.el sml-defs.el sml-move.el sml-mode.el \
- sml-proc.el
+ELFILES = sml-defs.el sml-move.el sml-mode.el sml-proc.el
default: elcfiles
+++ /dev/null
-;;; sml-compat.el --- Compatibility functions for Emacs variants for sml-mode
-
-;; 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 3 of the License, or
-;; (at your option) any later version.
-;;
-;; This program is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-;; GNU General Public License for more details.
-;;
-;; You should have received a copy of the GNU General Public License
-;; along with this program; if not, write to the Free Software
-;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-;;; Commentary:
-
-;;; Code:
-
-(require 'cl)
-
-(unless (fboundp 'set-keymap-parents)
- (defun set-keymap-parents (m parents)
- (if (keymapp parents) (setq parents (list parents)))
- (set-keymap-parent
- m
- (if (cdr parents)
- (reduce (lambda (m1 m2)
- (let ((m (copy-keymap m1)))
- (set-keymap-parent m m2) m))
- parents
- :from-end t)
- (car parents)))))
-
-;; for XEmacs
-(when (fboundp 'temp-directory)
- (defvar temporary-file-directory (temp-directory)))
-
-(unless (fboundp 'make-temp-file)
- ;; Copied from Emacs-21's subr.el
- (defun make-temp-file (prefix &optional dir-flag)
- "Create a temporary file.
-The returned file name (created by appending some random characters at the end
-of PREFIX, and expanding against `temporary-file-directory' if necessary,
-is guaranteed to point to a newly created empty file.
-You can then use `write-region' to write new data into the file.
-
-If DIR-FLAG is non-nil, create a new empty directory instead of a file."
- (let (file)
- (while (condition-case ()
- (progn
- (setq file
- (make-temp-name
- (expand-file-name prefix temporary-file-directory)))
- (if dir-flag
- (make-directory file)
- (write-region "" nil file nil 'silent))
- nil)
- (file-already-exists t))
- ;; the file was somehow created by someone else between
- ;; `make-temp-name' and `write-region', let's try again.
- nil)
- file)))
-
-
-
-(unless (fboundp 'regexp-opt)
- (defun regexp-opt (strings &optional paren)
- (let ((open (if paren "\\(" "")) (close (if paren "\\)" "")))
- (concat open (mapconcat 'regexp-quote strings "\\|") close))))
-
-
-;;;;
-;;;; Custom
-;;;;
-
-;; doesn't exist in Emacs < 20.1
-(unless (fboundp 'set-face-bold-p)
- (defun set-face-bold-p (face v &optional f)
- (when v (ignore-errors (make-face-bold face)))))
-(unless (fboundp 'set-face-italic-p)
- (defun set-face-italic-p (face v &optional f)
- (when v (ignore-errors (make-face-italic face)))))
-
-;; doesn't exist in Emacs < 20.1
-(ignore-errors (require 'custom))
-(unless (fboundp 'defgroup)
- (defmacro defgroup (&rest rest) ()))
-(unless (fboundp 'defcustom)
- (defmacro defcustom (sym val str &rest rest) `(defvar ,sym ,val ,str)))
-(unless (fboundp 'defface)
- (defmacro defface (sym val str &rest rest)
- `(defvar ,sym (make-face ',sym) ,str)))
-
-(defvar :group ':group)
-(defvar :type ':type)
-(defvar :copy ':copy)
-(defvar :dense ':dense)
-(defvar :inherit ':inherit)
-(defvar :suppress ':suppress)
-
-(provide 'sml-compat)
-
-;;; sml-compat.el ends here
;;; sml-defs.el --- Various definitions for sml-mode
-;; Copyright (C) 1999,2000,2003,2005,2007 Stefan Monnier <monnier@gnu.org>
+;; Copyright (C) 1999,2000,2003,2005,2007,2012 Stefan Monnier
;;
;; 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
;;; Code:
(eval-when-compile (require 'cl))
-(require 'sml-util)
-
(defgroup sml ()
"Editing SML code."
;;; Internal defines
;;;
-(defmap sml-mode-map
- ;; smarter cursor movement
- '((forward-sexp . sml-user-forward-sexp)
- (backward-sexp . sml-user-backward-sexp)
+(defvar sml-mode-map
+ (let ((map (make-sparse-keymap)))
+ ;; Smarter cursor movement.
+ ;; (define-key map [remap forward-sexp] 'sml-user-forward-sexp)
+ ;; (define-key map [remap backward-sexp] 'sml-user-backward-sexp)
;; Text-formatting commands:
- ("\C-c\C-m" . sml-insert-form)
- ("\C-c\C-i" . sml-mode-info)
- ("\M-|" . sml-electric-pipe)
- ("\M-\ " . sml-electric-space)
- ("\;" . sml-electric-semi)
- ("\M-\t" . sml-back-to-outer-indent)
+ (define-key map "\C-c\C-m" 'sml-insert-form)
+ (define-key map "\C-c\C-i" 'sml-mode-info)
+ (define-key map "\M-|" 'sml-electric-pipe)
+ (define-key map "\M-\ " 'sml-electric-space)
+ (define-key map "\;" 'sml-electric-semi)
+ (define-key map "\M-\t" 'sml-back-to-outer-indent)
;; Process commands added to sml-mode-map -- these should autoload
- ("\C-c\C-l" . sml-load-file)
- ("\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
- :group 'sml)
-
-(defsyntax sml-mode-syntax-table
- `((?\* . ,(if sml-builtin-nested-comments-flag ". 23n" ". 23"))
- (?\( . "()1")
- (?\) . ")(4")
- ("._'" . "_")
- (",;" . ".")
+ (define-key map "\C-c\C-l" 'sml-load-file)
+ (define-key map "\C-c\C-c" 'sml-compile)
+ (define-key map "\C-c\C-s" 'switch-to-sml)
+ (define-key map "\C-c\C-r" 'sml-send-region)
+ (define-key map "\C-c\C-b" 'sml-send-buffer)
+ (define-key map [(meta shift down-mouse-1)] 'sml-drag-region)
+ map)
+ "The keymap used in `sml-mode'.")
+
+(defconst sml-builtin-nested-comments-flag
+ (ignore-errors
+ (not (equal (let ((st (make-syntax-table)))
+ (modify-syntax-entry ?\* ". 23n" st) st)
+ (let ((st (make-syntax-table)))
+ (modify-syntax-entry ?\* ". 23" st) st))))
+ "Non-nil means this Emacs understands the `n' in syntax entries.")
+
+(defvar sml-mode-syntax-table
+ (let ((st (make-syntax-table)))
+ (modify-syntax-entry ?\* (if sml-builtin-nested-comments-flag
+ ". 23n" ". 23") st)
+ (modify-syntax-entry ?\( "()1" st)
+ (modify-syntax-entry ?\) ")(4" st)
+ (mapc (lambda (c) (modify-syntax-entry c "_" st)) "._'")
+ (mapc (lambda (c) (modify-syntax-entry c "." st)) ",;")
;; `!' is not really a prefix-char, oh well!
- ("~#!" . "'")
- ("%&$+-/:<=>?@`^|" . "."))
+ (mapc (lambda (c) (modify-syntax-entry c "'" st)) "~#!")
+ (mapc (lambda (c) (modify-syntax-entry c "." st)) "%&$+-/:<=>?@`^|")
+ st)
"The syntax table used in `sml-mode'.")
(concat "\\S.|\\S.\\|" (sml-syms-re (cdr sml-=-starter-syms)))
"Symbols that can be followed by a `='.")
+(defun sml-preproc-alist (al)
+ "Expand an alist AL where keys can be lists of keys into a normal one."
+ (reduce (lambda (x al)
+ (let ((k (car x))
+ (v (cdr x)))
+ (if (consp k)
+ (append (mapcar (lambda (y) (cons y v)) k) al)
+ (cons x al))))
+ al
+ :initial-value nil
+ :from-end t))
+
(defconst sml-indent-rule
(sml-preproc-alist
`(("struct" . 0)
;; (Stefan Monnier) <monnier@iro.umontreal.ca>
;; Maintainer: (Stefan Monnier) <monnier@iro.umontreal.ca>
;; Keywords: SML
-;; $Revision$
-;; $Date$
;; This file is not part of GNU Emacs, but it is distributed under the
;; same conditions.
;;; Code:
(eval-when-compile (require 'cl))
-(require 'sml-util)
(require 'sml-move)
(require 'sml-defs)
;; Code to handle nested comments and unusual string escape sequences
;;
-(defsyntax sml-syntax-prop-table
- '((?\\ . ".") (?* . "."))
+(defvar sml-syntax-prop-table
+ (let ((st (make-syntax-table)))
+ (modify-syntax-entry ?\\ "." st)
+ (modify-syntax-entry ?* "." st)
+ st)
"Syntax table for text-properties")
;; For Emacsen that have no built-in support for nested comments
the corresponding form is inserted."
(interactive)
(let ((abbrev-mode (not abbrev-mode))
- (last-command-char ?\ )
+ (last-command-event ?\ )
;; Bind `this-command' to fool skeleton's special abbrev handling.
(this-command 'self-insert-command))
(call-interactively 'self-insert-command)))
(let ((line (string-to-number (match-string 3)))
(char (string-to-number (match-string 4))))
(pop-to-buffer (find-file-noselect (match-string 2)))
- (goto-line line)
+ (goto-char (point-min))
+ (forward-line (1- line))
(forward-char (1- char)))))))
;;;
;;; sml-move.el --- Buffer navigation functions for sml-mode
-;; Copyright (C) 1999, 2000, 2004, 2007 Stefan Monnier <monnier@gnu.org>
+;; Copyright (C) 1999,2000,2004,2007,2012 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
;;; Code:
(eval-when-compile (require 'cl))
-(require 'sml-util)
(require 'sml-defs)
-(defsyntax sml-internal-syntax-table
- '((?_ . "w")
- (?' . "w")
- (?. . "w")
- ;; treating `~' as a word constituent is not quite right, but
+(defvar sml-internal-syntax-table
+ (let ((st (make-syntax-table sml-mode-syntax-table)))
+ (modify-syntax-entry ?_ "w" st)
+ (modify-syntax-entry ?' "w" st)
+ (modify-syntax-entry ?. "w" st)
+ ;; Treating `~' as a word constituent is not quite right, but
;; close enough. Think about 12.3E~2 for example. Also `~' on its
;; own *is* a nonfix symbol.
- (?~ . "w"))
- "Syntax table used for internal sml-mode operation."
- :copy sml-mode-syntax-table)
+ (modify-syntax-entry ?~ "w" st)
+ st)
+ "Syntax table used for internal sml-mode operation.")
;;;
;;; various macros
t))
;;;
-;;; read a symbol, including the special "op <sym>" case
+;;; Read a symbol, including the special "op <sym>" case
;;;
(defmacro sml-move-read (&rest body)
;;; sml-proc.el --- Comint based interaction mode for Standard ML.
-;; Copyright (C) 1999, 2000, 2003, 2004, 2005, 2007 Stefan Monnier
+;; Copyright (C) 1999,2000,2003,2004,2005,2007,2012 Stefan Monnier
;; Copyright (C) 1994-1997 Matthew J. Morley
;; Copyright (C) 1989 Lars Bo Nielsen
-;; $Revision$
-;; $Date$
-
;; ====================================================================
;; This file is not part of GNU Emacs, but it is distributed under the
(eval-when-compile (require 'cl))
(require 'sml-mode)
-(require 'sml-util)
(require 'comint)
(require 'compile)
;;; CODE
-(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 comint-mode-map
- :group 'sml-proc)
-
+(defvar inferior-sml-mode-map
+ (let ((map (make-sparse-keymap)))
+ (set-keymap-parent map comint-mode-map)
+ (define-key map "\C-c\C-s" 'run-sml)
+ (define-key map "\C-c\C-l" 'sml-load-file)
+ (define-key map "\t"
+ (if (fboundp 'completion-at-point)
+ 'completion-at-point 'comint-dynamic-complete))
+ map)
+ "Keymap for inferior-sml mode")
;; buffer-local
+++ /dev/null
-;;; sml-util.el --- Utility functions for sml-mode
-
-;; Copyright (C) 1999-2000, 2007, 2010 Stefan Monnier <monnier@iro.umontreal.ca>
-;;
-;; 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 3 of the License, or
-;; (at your option) any later version.
-;;
-;; This program is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-;; GNU General Public License for more details.
-;;
-;; You should have received a copy of the GNU General Public License
-;; along with this program; if not, write to the Free Software
-;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-
-;;; Commentary:
-
-;;; Code:
-
-(require 'cl) ;for `reduce'
-(require 'sml-compat)
-
-(defun sml-preproc-alist (al)
- "Expand an alist AL where keys can be lists of keys into a normal one."
- (reduce (lambda (x al)
- (let ((k (car x))
- (v (cdr x)))
- (if (consp k)
- (append (mapcar (lambda (y) (cons y v)) k) al)
- (cons x al))))
- al
- :initial-value nil
- :from-end t))
-
-;;;
-;;; defmap
-;;;
-
-(defun custom-create-map (m bs args)
- (let (inherit dense suppress)
- (while args
- (let ((key (first args))
- (val (second args)))
- (cond
- ((eq key :dense) (setq dense val))
- ((eq key :inherit) (setq inherit val))
- ((eq key :group) )
- ;;((eq key :suppress) (setq suppress val))
- (t (message "Uknown argument %s in defmap" key))))
- (setq args (cddr args)))
- (unless (keymapp m)
- (setq bs (append m bs))
- (setq m (if dense (make-keymap) (make-sparse-keymap))))
- (dolist (b bs)
- (let ((keys (car b))
- (binding (cdr b)))
- (dolist (key (if (consp keys) keys (list keys)))
- (cond
- ((symbolp key)
- (substitute-key-definition key binding m global-map))
- ((null binding)
- (unless (keymapp (lookup-key m key)) (define-key m key binding)))
- ((let ((o (lookup-key m key)))
- (or (null o) (numberp o) (eq o 'undefined)))
- (define-key m key binding))))))
- (cond
- ((keymapp inherit) (set-keymap-parent m inherit))
- ((consp inherit) (set-keymap-parents m inherit)))
- m))
-
-(defmacro defmap (m bs doc &rest args)
- `(defvar ,m
- (custom-create-map (if (boundp ',m) ,m) ,bs ,(cons 'list args))
- ,doc))
-
-;; defsyntax ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(defun custom-create-syntax (css args)
- (let ((st (make-syntax-table (cadr (memq :copy args)))))
- (dolist (cs css)
- (let ((char (car cs))
- (syntax (cdr cs)))
- (if (sequencep char)
- (mapcar* (lambda (c) (modify-syntax-entry c syntax st)) char)
- (modify-syntax-entry char syntax st))))
- st))
-
-(defmacro defsyntax (st css doc &rest args)
- `(defvar ,st (custom-create-syntax ,css ,(cons 'list args)) ,doc))
-
-;;;;
-;;;; Compatibility info
-;;;;
-
-(defvar sml-builtin-nested-comments-flag
- (ignore-errors
- (not (equal (let ((st (make-syntax-table)))
- (modify-syntax-entry ?\* ". 23n" st) st)
- (let ((st (make-syntax-table)))
- (modify-syntax-entry ?\* ". 23" st) st))))
- "Non-nil means this Emacs understands the `n' in syntax entries.")
-
-(provide 'sml-util)
-
-;;; sml-util.el ends here