X-Git-Url: https://code.delx.au/gnu-emacs-elpa/blobdiff_plain/d711ac599cf1be6d5aea88709a1caf7195587010..2e6b4f66cf6bc14868f23a350063922de3b37d0c:/packages/sml-mode/sml-mode.el diff --git a/packages/sml-mode/sml-mode.el b/packages/sml-mode/sml-mode.el index beca44994..1c06f1600 100644 --- a/packages/sml-mode/sml-mode.el +++ b/packages/sml-mode/sml-mode.el @@ -1,18 +1,17 @@ ;;; sml-mode.el --- Major mode for editing (Standard) ML -*- lexical-binding: t; coding: utf-8 -*- -;; Copyright (C) 1989,1999,2000,2004,2007,2010-2012 Free Software Foundation, Inc. +;; Copyright (C) 1989,1999,2000,2004,2007,2010-2013 Free Software Foundation, Inc. ;; Maintainer: (Stefan Monnier) -;; Version: 6.0 +;; Version: 6.4 ;; Keywords: SML -;; Authors of previous versions: -;; Lars Bo Nielsen -;; Olin Shivers -;; Fritz Knabe (?) -;; Steven Gilmore (?) -;; Matthew Morley -;; Matthias Blume -;; (Stefan Monnier) +;; Author: Lars Bo Nielsen +;; Olin Shivers +;; Fritz Knabe (?) +;; Steven Gilmore (?) +;; Matthew Morley +;; Matthias Blume +;; (Stefan Monnier) ;; This file is part of GNU Emacs. @@ -43,6 +42,75 @@ ;; - outline-minor-mode (with some known problems). ;; - Interaction with a read-eval-print loop. +;;;; Known bugs: + +;; - Indentation after "functor toto() where type foo = bar =" +;; Because the last is treated as an equality comparison. +;; - indentation of a declaration after a long `datatype' can be slow. + +;;;; News: + +;;;;; Changes since 5.0: + +;; - sml-electric-pipe-mode to make the | key electric. +;; - Removal of a lot of compatibility code. Requires Emacs-24. +;; - Integrate in GNU ELPA. + +;;;;; Changes since 4.1: + +;; - New indentation code using SMIE when available. +;; - `sml-back-to-outer-indent' is now on S-tab (aka `backtab') rather +;; than M-tab. +;; - Support for electric-layout-mode and electric-indent-mode. +;; - `sml-mark-defun' tries to be more clever. +;; - A single file (sml-mode.el) is needed unless you want to use an +;; interactive process like SML/NJ, or if your Emacs does not provide SMIE. + +;;;;; Changes since 4.0: + +;; - Switch to GPLv3+. +;; - When possible (i.e. running under Emacs>=23), be case-sensitive when +;; expanding abbreviations, and don't expand them in comments and strings. +;; - When you `next-error' to a type error, highlight the actual parts of the +;; types that differ. +;; - Flush the recorded errors not only upon sml-compile and friends, but also +;; when typing commands directly at the prompt. +;; - New command sml-mlton-typecheck. +;; - Simple support to parse errors and warnings in MLton's output. +;; - Simple support for MLton's def-use files. + +;;;;; Changes since 3.9.5: + +;; - No need to add the dir to your load-path any more. +;; The sml-mode-startup.el file does it for you. +;; - Symbols like -> can be displayed as real arrows. +;; See sml-font-lock-symbols. +;; - Fix some incompatibilities with the upcoming Emacs-21.4. +;; - Indentation rules improved. New customizable variable +;; `sml-rightalign-and'. Also `sml-symbol-indent' is now customizable. + +;;;;; Changes since 3.9.3: + +;; - New add-log support (try C-x 4 a from within an SML function). +;; - Imenu 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. +;; - `sml-compile' works yet a bit differently. The command can begin +;; 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 a prefix argument if you want to give args or to specify a host on +;; which to run the command. +;; - mouse-2 to yank in *sml* should work again (but won't work for next-error +;; any more). +;; - New major-modes sml-cm-mode, sml-lex-mode and sml-yacc-mode. +;; - 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 site-start.el. +;; - Minor bug fixes. + ;;; Code: (eval-when-compile (require 'cl)) @@ -96,6 +164,8 @@ notion of \"the end of an outline\".") (define-key map "\M-|" 'sml-electric-pipe) (define-key map "\M-\ " 'sml-electric-space) (define-key map [backtab] 'sml-back-to-outer-indent) + ;; The standard binding is C-c C-z, but we add this one for compatibility. + (define-key map "\C-c\C-s" 'sml-prog-proc-switch-to) map) "The keymap used in `sml-mode'.") @@ -116,7 +186,7 @@ notion of \"the end of an outline\".") (easy-menu-define sml-mode-menu sml-mode-map "Menu used in `sml-mode'." '("SML" ("Process" - ["Start SML repl" run-sml t] + ["Start SML repl" sml-run t] ["-" nil nil] ["Compile the project" sml-prog-proc-compile t] ["Send file" sml-prog-proc-load-file t] @@ -424,6 +494,7 @@ Regexp match data 0 points to the chars." (basic sml-indent-level) (args sml-indent-args))) (:list-intro (member token '("fn"))) + (:close-all t) (:after (cond ((equal token "struct") 0) @@ -586,7 +657,7 @@ Assumes point is right before the | symbol." ;;;; Imenu support ;;;; -(defvar sml-imenu-regexp +(defconst sml-imenu-regexp (concat "^[ \t]*\\(let[ \t]+\\)?" (regexp-opt (append sml-module-head-syms '("and" "fun" "datatype" "abstype" "type")) t) @@ -608,9 +679,9 @@ Assumes point is right before the | symbol." (name (sml-smie-forward-token))) ;; Eliminate trivial renamings. (when (or (not (member kind '("structure" "signature"))) - (progn (search-forward "=") - (forward-comment (point-max)) - (looking-at "sig\\|struct"))) + (when (search-forward "=" nil t) + (forward-comment (point-max)) + (looking-at "sig\\|struct"))) (push (cons (concat (make-string (/ column 2) ?\ ) name) location) alist))))) alist)) @@ -687,6 +758,7 @@ Assumes point is right before the | symbol." (defun sml-prog-proc-switch-to () "Switch to the buffer running the read-eval-print process." + (interactive) (pop-to-buffer (sml-prog-proc-buffer))) (defun sml-prog-proc-send-string (proc str) @@ -762,6 +834,11 @@ AND-GO if non-nil indicate to additionally switch to the process's buffer." (car sml-prog-proc--tmp-file))) str) +(defvar sml-prog-proc-comint-mode-map + (let ((map (make-sparse-keymap))) + (define-key map "\C-c\C-l" 'sml-prog-proc-load-file) + map)) + (define-derived-mode sml-prog-proc-comint-mode comint-mode "Sml-Prog-Proc-Comint" "Major mode for an inferior process used to run&compile source code." ;; Enable compilation-minor-mode, but only after the child mode is setup @@ -964,6 +1041,10 @@ See `compilation-error-regexp-alist' for a description of the format.") (read-string "On host: " sml-host-name) sml-host-name))) +;;;###autoload +(defalias 'run-sml 'sml-run) + +;;;###autoload (defun sml-run (cmd arg &optional host) "Run the program CMD with given arguments ARG. The command is run in buffer *CMD* using mode `inferior-sml-mode'. @@ -1014,8 +1095,7 @@ With a prefix argument AND-GO switch to the repl buffer as well." (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 "\C-c\C-s" 'sml-run) (define-key map "\t" 'completion-at-point) map) "Keymap for inferior-sml mode.") @@ -1122,7 +1202,7 @@ TAB file name completion, as in shell-mode, etc.." (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) '(?/ . ?\")) + (set (make-local-variable 'comint-completion-addsuffix) '("/" . "\"")) (set (make-local-variable 'font-lock-defaults) inferior-sml-font-lock-defaults) @@ -1148,7 +1228,6 @@ TAB file name completion, as in shell-mode, etc.." This mode runs `sml-mode-hook' just before exiting. See also (info \"(sml-mode)Top\"). \\{sml-mode-map}" - (set (make-local-variable 'sml-prog-proc-descriptor) sml-pp-functions) (set (make-local-variable 'font-lock-defaults) sml-font-lock-defaults) (set (make-local-variable 'outline-regexp) sml-outline-regexp) (set (make-local-variable 'imenu-create-index-function) @@ -1175,6 +1254,7 @@ See also (info \"(sml-mode)Top\"). (sml-mode-variables)) (defun sml-mode-variables () + (set (make-local-variable 'sml-prog-proc-descriptor) sml-pp-functions) (set-syntax-table sml-mode-syntax-table) (setq local-abbrev-table sml-mode-abbrev-table) ;; Setup indentation and sexp-navigation.