+++ /dev/null
-2012-10-19 Stefan Monnier <monnier@iro.umontreal.ca>
-
- * sml-mode.el (sml-electric-pipe-mode): New var.
- (sml-pipeheads): Add (, {, and [ to more reliably detect cases where
- the pipe is not part of a case/fun/...
- (sml-tyvarseq-re): Use shy groups.
- (sml-font-lock-keywords): Adjust accordingly.
- (sml-compile): Avoid the 3rd part of dolist's spec.
- (sml-post-self-insert-pipe): New fun, extracted from sml-electric-pipe.
- (sml-mode): Use it to obey sml-electric-pipe-mode.
- (sml-electric-pipe): Use sml-post-self-insert-pipe.
-
- * prog-proc.el: Rename from sml-prog-proc.el.
-
- * makefile.pkg (ELFILES): Remove sml-proc.el.
-
-2012-04-11 Stefan Monnier <monnier@iro.umontreal.ca>
-
- Merge sml-defs.el into sml-mode.el.
- * sml-mode.el: Merge code from sml-defs.el.
- Remove ":group 'sml" since they're now redundant.
- * makefile.pkg (ELFILES): Adjust.
-
-2012-04-11 Stefan Monnier <monnier@iro.umontreal.ca>
-
- * sml-mode.el (sml-mark-function): New implementation using SMIE.
- * sml-defs.el (sml-mode-map): Use backtab.
- Remove leftover unused sml-drag-region binding.
-
-2012-04-11 Stefan Monnier <monnier@iro.umontreal.ca>
-
- Use SMIE by default and make sml-oldindent optional.
- * sml-mode.el: Only load sml-oldindent if necessary.
- (sml-use-smie): Default to t.
- (sml-smie-datatype-|-p): Better handle incomplete datatype branch.
- (sml-mode): Use prog-mode. Setup electric-layout and electric-indent.
- (sml-mode-variables): Always setup SMIE if possible.
- (sml-imenu-create-index, sml-funname-of-and, sml-electric-pipe)
- (sml-beginning-of-defun, sml-defuse-symdata-at-point)
- (sml-yacc-font-lock-keywords, sml-yacc-indentation):
- Avoid sml-oldindent functions.
- (sml-find-forward): Move from sml-oldindent and re-implement.
- (sml-electric-semi): Use self-insert-command so electric-layout and
- electric-indent can do their job.
- (sml-smie-find-matching-starter, sml-find-matching-starter)
- (sml-smie-skip-siblings, sml-skip-siblings): New functions.
- * sml-oldindent.el (sml-starters-indent-after, sml-exptrail-syms):
- Remove, unused.
- (sml-find-forward): Move back to sml-mode.el.
- (sml-old-find-matching-starter): Rename from sml-find-matching-starter.
- (sml-old-skip-siblings): Move&rename from sml-mode:sml-skip-siblings.
-
-2012-04-11 Stefan Monnier <monnier@iro.umontreal.ca>
-
- Move non-SMIE indentation code to a separate file.
- * sml-oldindent.el: Rename from sml-move.el.
- * makefile.pkg (ELFILES): Adjust.
- * sml-mode.el (sml-indent-line, sml-find-comment-indent)
- (sml-calculate-indentation, sml-bolp, sml-first-starter-p)
- (sml-indent-starter, sml-indent-relative, sml-indent-pipe)
- (sml-find-forward, sml-indent-arg, sml-get-indent, sml-dangling-sym)
- (sml-delegated-indent, sml-get-sym-indent, sml-indent-default)
- (sml-current-indentation, sml-find-matching-starter):
- Move to sml-oldindent.el.
- (comment-quote-nested, compilation-error-regexp-alist): Declare.
-
- * sml-defs.el (sml-begin-syms, sml-begin-syms-re)
- (sml-sexp-head-symbols-re, sml-preproc-alist, sml-indent-rule)
- (sml-starters-indent-after, sml-delegate, sml-symbol-indent)
- (sml-open-paren, sml-close-paren, sml-agglomerate-re)
- (sml-exptrail-syms): Move to sml-oldindent.el.
-
-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)
- (sml-smie-non-nested-of-p, sml-smie-datatype-|-p)
- (sml-smie-forward-token-1, sml-smie-forward-token)
- (sml-smie-backward-token-1, sml-smie-backward-token): New functions.
- (sml-mode): Don't set forward-sexp-function.
- (sml-mode-variables): Set it here instead, and setup SMIE instead
- if applicable.
-
-2010-03-04 Stefan Monnier <monnier@iro.umontreal.ca>
-
- * Release version 4.1.
-
- * sml-mode.el: Don't setup load-path here any more.
- * Makefile ($(PACKAGE)-startup.el): Recreate from scratch every time.
- Setup load-path.
- (dist): Try to update it to use Svn rather than CVS.
-
-2007-11-08 Stefan Monnier <monnier@iro.umontreal.ca>
-
- * sml-proc.el (inferior-sml-next-error-hook): Make it match one
- more format.
-
-2007-10-31 Stefan Monnier <monnier@iro.umontreal.ca>
-
- * testcases.sml: Add (old) buggy case from Christopher Dutchyn.
-
- * sml-proc.el (inferior-sml-font-lock-keywords): Don't add
- error-regexps if compile.el already highlights them anyway.
-
- * sml-mode.el (sml-font-lock-symbols-alist): Fix char for "not".
-
-2007-10-31 Stefan Monnier <monnier@iro.umontreal.ca>
-
- * sml-mode.el (sml-def-skeleton): If possible, only expand for
- lower-case abbrevs and not inside strings or comments.
- (sml-mlton-typecheck): Typo.
-
- * sml-proc.el (sml-proc-comint-input-filter-function): New function.
- (inferior-sml-mode): Use it.
- (sml-update-cursor): Don't forget errors here any more.
-
-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.
- (sml-mlton-typecheck): Use it.
- (compilation-error-regexp-alist): Add entries after loading "compile"
- so that M-x compile works.
-
- * sml-proc.el (inferior-sml-mode): Make TAB add a " rather than a space
- at the end of a file name.
-
-2007-06-14 Stefan Monnier <monnier@iro.umontreal.ca>
-
- * sml-mode.el (sml-mode-variables): Set comment-quote-nested instead of
- comment-nested. Set comment-end-skip.
- (sml-first-starter-p): New function.
- (sml-indent-starter): Use it to fix an indentation bug.
- (sml-mlton-command, sml-mlton-mainfile): New vars.
- (sml-mlton-typecheck): New command.
- (sml-defuse-file): New var.
- (sml-defuse-def-regexp, sml-defuse-use-regexp-format): New consts.
- (sml-defuse-file, sml-defuse-symdata-at-point): New functions.
- (sml-defuse-set-file, sml-defuse-jump-to-def): New commands.
-
-2005-11-20 Stefan Monnier <monnier@iro.umontreal.ca>
-
- * sml-move.el (sml-find-match-forward): Avoid infinite looping if the
- construct is not properly closed (yet).
-
-2005-11-16 Stefan Monnier <monnier@iro.umontreal.ca>
-
- * sml-defs.el (sml-mode-menu): Remove left over obsolete entries.
-
- * sml-proc.el (inferior-sml-mode): Preserve the menu-bar of the
- compilation minor mode, if any.
-
-2004-11-24 Stefan Monnier <monnier@iro.umontreal.ca>
-
- * Release version 4.0.
-
-2004-11-23 Stefan Monnier <monnier@iro.umontreal.ca>
-
- * sml-mode.el (sml-font-lock-symbols-alist): Add yet more silly entries.
-
-2004-11-15 Stefan Monnier <monnier@iro.umontreal.ca>
-
- * sml-mode.el (sml-font-lock-symbols-alist): Add entries for >= and <=.
- (sml-font-lock-symbols-alist): Add entries for simple type variables.
- (sml-font-lock-compose-symbol): Add support for non-punctuation syms.
-
-2004-11-14 Stefan Monnier <monnier@iro.umontreal.ca>
-
- * sml-move.el (sml-backward-sexp, sml-forward-sexp): Remove unused var.
-
- * sml-mode.el (sml-calculate-indentation): Remove unused var.
- (sml-get-indent): Change first arg's meaning.
- (sml-get-sym-indent): Adjust call.
- (sml-forms-menu): Simplify.
- (sml-font-lock-symbols, sml-font-lock-symbols-alist): New vars.
- (sml-font-lock-compose-symbol, sml-font-lock-symbols-keywords):
- New funs.
- (sml-font-lock-keywords): Use them.
-
- * sml-compat.el (temp-directory): Get rid of warning.
-
- * Makefile (install_startup): Don't add to load-path any more.
-
- * sml-proc.el (sml-make-error): Use match-string.
- (sml-error-regexp-alist): Merge regexps.
- (sml-update-cursor): Check sml-temp-file is non-nil.
-
-2004-04-21 Stefan Monnier <monnier@iro.umontreal.ca>
-
- * sml-proc.el (sml-error-regexp-alist): Use new compile.el features
- if available.
- (sml-send-region): Remove unused var `file'.
- (sml-drag-region): Remove unused function.
- (sml-update-cursor): Use compilation-fake-loc if available.
- (compilation-goto-locus): Only advise if necessary.
-
- * sml-mode.el: Add self to load-path in sml-mode-startup.el.
- (sml-def-skeleton): Try to use the new `system' abbrev flag.
-
-2004-04-04 Stefan Monnier <monnier@iro.umontreal.ca>
-
- * testcases.sml: Add a nasty case that is still wrong.
-
- * sml-proc.el (sml-error-regexp-alist): Tune the regexp for sml/nj.
-
- * sml-mode.el (sml-mode): Better handle paragraphs in comments.
- (sml-mode-variables): Clean up paragraph settings.
- (sml-electric-pipe): Fix a boundary bug.
- (sml-indent-starter, sml-get-sym-indent, sml-find-matching-starter):
- Fix indentation algorithm. Can't remember what it was about.
- This code is nasty, I just can't understand what's doing what.
- (completion-ignored-extensions): Add the new .cm directory.
-
-2003-12-09 Stefan Monnier <monnier@iro.umontreal.ca>
-
- * sml-defs.el (sml-mode-menu): Fix typo. Use std names.
- (sml-begin-syms-re): Reduce redundancy.
-
-2001-09-18 Stefan Monnier <monnier@cs.yale.edu>
-
- * sml-mode.el (sml-tyvarseq-re): Fix typo.
-
-2001-07-20 Stefan Monnier <monnier@cs.yale.edu>
-
- * sml-mode.el (sml-rightalign-and): New defcustom.
- (sml-tyvarseq-re): New var.
- (sml-font-lock-keywords): Use it.
- (sml-imenu-create-index): Don't get confused by tyvarseq's.
- (sml-mode-variables): Don't set `comment-column'.
- (sml-funname-of-and): New function.
- (sml-electric-pipe): Use it.
- (sml-find-comment-indent): Try to ignore comment-markers in strings.
- (sml-calculate-indentation): Handle closing parens specially.
- (sml-indent-pipe): Recognize the case where `and' defines a datatype.
- (sml-dangling-sym): Make it work if the symbol is an open-paren.
- (sml-indent-default): Change the behavior when preceded by `end',
- although I'm not quite sure why.
- Understand dangling open-parens.
- Properly skip *all* subexpressions of lower precedence.
- Allow use of sml-symbol-indent to outdent lines starting with , or ;.
- (sml-insert-form): Use preceding-char to avoid bug at bobp.
-
-2001-07-19 Stefan Monnier <monnier@cs.yale.edu>
-
- * sml-proc.el (sml-proc-buffer): Save excursion when calling run-sml.
-
- * sml-move.el (sml-syntax-prec): Split ; and , from `in' and `with'.
-
- * sml-mode.texi: Put the entry in `Emacs' rather than `Editors'.
-
- * sml-mode.spec (BuildArch): Simplify call to `install-info'.
-
- * sml-defs.el (sml-mode-menu): Add an explicit t for always-active.
- (sml-symbol-indent): Add entries for , and ; and turn into defcustom.
-
- * sml-compat.el: Add more stuff. It might help for Emacs-19.34.
-
- * makefile.pkg (test): Use elisp files in current dir.
-
-2000-12-24 Stefan Monnier <monnier@cs.yale.edu>
-
- * Release version 3.9.5.
-
- * Makefile (install): Also install .el files.
- (dist): Don't rely on $CVSROOT.
-
- * sml-mode.el: Require `skeleton'.
- (sml-mode): Add the menu for XEmacs. Make sure @ is a valid skeleton.
- (sml-comment-indent): Remove.
- (sml-mode-variables): Don't set comment-indent-function.
- (sml-def-skeleton): Nop if skeletons aren't available.
- (skeletons): Use `> _' and `@'.
- (sml-forms-menu): Don't bother with easy-menu-filter-return crap.
- (sml-cm-mode-syntax-table, sml-cm-font-lock-keywords): New vars.
- (sml-cm-mode): Use define-derived-mode rather than define-generic-mode.
- (sml-lex-font-lock-keywords, sml-lex-font-lock-defaults): New vars.
- (sml-yacc-font-lock-keywords): Use sml-lex-font-lock-keywords.
- Refine pattern to recognize the %prec keyword.
- (sml-yacc-font-lock-defaults): Fix typo.
-
- * sml-proc.el (inferior-sml-mode): Disable next-error for XEmacs.
-
- * sml-util.el (defsyntax): Don't forget to eval `doc'.
-
- * sml-mode.spec: Simplify.
-
- * sml-defs.el (sml-mode-menu): Remove bogus entry for sml-mode-version.
-
-2000-10-06 Stefan Monnier <monnier@cs.yale.edu>
-
- * sml-mode.el: Make the toplevel closer to usual practice.
- (sml-imenu-regexp, sml-imenu-create-index): New var and fun.
- (sml-mode): Use them.
- (sml-beginning-of-defun): Add `and' as function-leader.
- (sml-lex-mode): New trivial mode.
- (sml-yacc-bnf-face, sml-yacc-indent-action, sml-yacc-indent-pipe)
- (sml-yacc-indent-term, sml-yacc-font-lock-keywords)
- (sml-yacc-font-lock-defaults): New vars.
- (sml-yacc-indent-line, sml-yacc-indentation, sml-yacc-mode): New funs.
-
- * sml-mode.texi: Added yours truly to the list of authors.
-
- * sml-mode.spec: New file.
-
- * sml-defs.el (sml-outline-regexp): Slightly improved regexp.
-
-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 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.
- (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.
- (sml-indent-line): Ignore errors and keep the cursor where it is.
- (sml-calculate-indentation, sml-indent-pipe): Use syms instead of REs.
-
- * sml-defs.el (sml-starters-re, sml-pipehead-re): Remove.
-
- * testcases.sml: New file.
-
- * makefile.pkg (test): New target to run the test suite.
-
-2000-02-18 Stefan Monnier <monnier@cs.yale.edu>
-
- * *.el: Pass through checkdoc and use `eval-when-compile' whenever
- possible for (require 'cl).
-
-2000-02-18 Stefan Monnier <monnier@cs.yale.edu>
-
- * sml-util.el (make-temp-dir, make-temp-file, temp-file-dir)
- (delete-temp-dirs): Replace by the make-temp-file from Emacs-21.
- (custom-create-map): Add :group arg and allow key to be a list.
- (define-major-mode): Remove (use define-derived-mode instead).
- (sml-builtin-nested-comments-flag): New var.
- (concatq): Remove.
-
- * sml-proc.el (sml-host-name): New var.
- (sml-make-file-name): Replace by `sml-compile-commands'.
- (sml-config-file): New var.
- (sml-compile-commands-alist): New var.
- (inferior-sml-load-hook): Remove.
- (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.
- (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.
- 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.
- (sml-make-error): Fix for when `endline' is absent.
-
- * sml-mode.el: Pass it through checkdoc.
- (sml-mode-version): Remove.
- (sml-load-hook): Remove.
- (sml-mode-info): Use `info' rather than `Info-goto-node'.
- (sml-keywords-regexp): Add "o".
- (sml-syntax-prop-table): Use `defsyntax'.
- (sml-font-lock-syntactic-keywords): Only use nested comments if supported.
- (sml-mode): Use `define-derived-mode'.
- (sml-electric-pipe): `sml-indent-line' -> `indent-according-to-mode'.
- (sml-indent-line): Use `indent-line-to'.
- (sml-cm-mode): New mode for CM files.
-
- * Makefile: Update.
-
- * sml-mode-startup.el: Remove since it's now auto-generated.
-
- * sml-defs.el (sml-bindings): Remove left over C-c` binding.
- (sml-mode-map): Add binding for sml-drag-region (was in sml-proc.el).
- (sml-mode-syntax-table): Only use nested comments if supported.
- (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.
- (temporary-file-directory): Add a default definition for XEmacs.
- (make-temp-file): New function.
-
-1999-08-11 Stefan Monnier <monnier@cs.yale.edu>
-
- * Release version 3.9.3.
-
- * sml-mode.texi: Somewhat update the doc.
-
-1999-08-09 Stefan Monnier <monnier@cs.yale.edu>
-
- * Makefile: Update to the version of pcl-cvs.
-
- * sml-proc.el: Eliminate some old unused code.
-
- * 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-mode.el (sml-indent): Fix the `fixindent'.
-
-1999-06-22 Stefan Monnier <monnier@cs.yale.edu>
-
- * sml-mode-startup.el: Fix to fulfill autoload.el assumptions.
-
-1999-06-21 Stefan Monnier <monnier@cs.yale.edu>
-
- * 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-startup.el: Update the autoloads automatically.
-
-1999-06-19 Stefan Monnier <monnier@cs.yale.edu>
-
- * Release version 3.9.2
-
- * sml-proc.el (sml-error-regexp-alist): Fix the pathological
- font-locking on long lines.
-
- * 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-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): Distinguish between
- operator "=" and syntax for definitions "d=".
-
- * 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): 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-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.
-
- * version 3.9.1: sent to Roland McGrath.
-
-1999-06-13 Stefan Monnier <monnier@cs.yale.edu>
-
- * sml-smlnj.el, sml-mosml.el, sml-poly-ml.el: Remove.
-
- * 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): Drop: always use a temp file.
-
-1999-06-10 Stefan Monnier <monnier@cs.yale.edu>
-
- * 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): 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): 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
-
-1999-05-29 Stefan Monnier <monnier@cs.yale.edu>
-
- * sml-defs.el (sml-mode-syntax-table): Add ~ 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'.
-
-1999-05-28 Stefan Monnier <monnier@cs.yale.edu>
-
- * 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.
-
-1998-10-26 Stefan Monnier <monnier@cs.yale.edu>
-
- * sml-mode.el (sml-font-lock-syntactic-keywords):
- Add syntactic-keywords to support nested comments.
-
PACKAGE = sml-mode
-ELFILES = sml-mode.el prog-proc.el
+ELFILES = sml-mode.el
default: elcfiles
+++ /dev/null
-;;; prog-proc.el --- Interacting from a source buffer with an inferior process -*- lexical-binding: t; coding: utf-8 -*-
-
-;; Copyright (C) 1999,2000,2003,2004,2005,2007,2012 Stefan Monnier
-;; Copyright (C) 1994-1997 Matthew J. Morley
-;; Copyright (C) 1989 Lars Bo Nielsen
-
-;; ====================================================================
-
-;; This file is not part of GNU Emacs, but it is distributed under the
-;; same conditions.
-
-;; 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, 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 GNU Emacs; see the file COPYING. If not, write to the
-;; Free Software Foundation, 675 Mass Ave, Cambridge, MA 0139, USA.
-;; (See sml-mode.el for HISTORY.)
-
-;; ====================================================================
-
-;;; Commentary:
-
-;; Prog-Proc is a package designed to complement Comint: while Comint was
-;; designed originally to handle the needs of inferior process buffers, such
-;; as a buffer running a Scheme repl, Comint does not actually provide any
-;; functionality that links this process buffer with some source code.
-;;
-;; That's where Prog-Proc comes into play: it provides the usual commands and
-;; key-bindings that lets the user send his code to the underlying repl.
-
-;;; Code:
-
-(eval-when-compile (require 'cl))
-(require 'comint)
-(require 'compile)
-
-(defvar prog-proc-mode-map
- (let ((map (make-sparse-keymap)))
- (define-key map [?\C-c ?\C-l] 'prog-proc-load-file)
- (define-key map [?\C-c ?\C-c] 'prog-proc-compile)
- (define-key map [?\C-c ?\C-z] 'prog-proc-switch-to)
- (define-key map [?\C-c ?\C-r] 'prog-proc-send-region)
- (define-key map [?\C-c ?\C-b] 'prog-proc-send-buffer)
- map)
- "Keymap for `prog-proc-mode'.")
-
-(defvar prog-proc--buffer nil
- "The inferior-process buffer to which to send code.")
-(make-variable-buffer-local 'prog-proc--buffer)
-
-(defstruct (prog-proc-functions
- (:constructor prog-proc-make)
- (:predicate nil)
- (:copier nil))
- (name :read-only t)
- (run :read-only t)
- (load-cmd :read-only t)
- (chdir-cmd :read-only t)
- (compile-commands-alist :read-only t))
-
-(defvar prog-proc-functions nil
- "Struct containing the various functions to create a new process, ...")
-
-(defmacro prog-proc--prop (prop)
- `(,(intern (format "prog-proc-functions-%s" prop))
- (or prog-proc-functions
- ;; FIXME: Look for available ones and pick one.
- (error "Not an `prog-proc' buffer"))))
-(defmacro prog-proc--call (method &rest args)
- `(funcall (prog-proc--prop ,method) ,@args))
-
-;; The inferior process and his buffer are basically interchangeable.
-;; Currently the code takes prog-proc--buffer as the main reference,
-;; but all users should either use prog-proc-proc or prog-proc-buffer
-;; to find the info.
-
-(defun prog-proc-proc ()
- "Return the inferior process for the code in current buffer."
- (or (and (buffer-live-p prog-proc--buffer)
- (get-buffer-process prog-proc--buffer))
- (when (derived-mode-p 'prog-proc-mode 'prog-proc-comint-mode)
- (setq prog-proc--buffer (current-buffer))
- (get-buffer-process prog-proc--buffer))
- (let ((buf (prog-proc--call run)))
- (setq prog-proc--buffer buf)
- (get-buffer-process prog-proc--buffer))))
-
-(defun prog-proc-buffer ()
- "Return the buffer of the inferior process."
- (process-buffer (prog-proc-proc)))
-
-(defun prog-proc-switch-to ()
- "Switch to the buffer running the read-eval-print process."
- (pop-to-buffer (prog-proc-buffer)))
-
-(defun prog-proc-send-string (proc str)
- (with-current-buffer (process-buffer proc)
- ;; FIXME: comint-send-string does not pass the string through
- ;; comint-input-filter-function, so we have to do it by hand.
- ;; Maybe we should insert the command into the buffer and then call
- ;; comint-send-input?
- (prog-proc-comint-input-filter-function nil)
- (comint-send-string proc (concat str "\n"))))
-
-(defun prog-proc-load-file (file &optional and-go)
- "Load FILE into the read-eval-print process.
-FILE is the file visited by the current buffer.
-If prefix argument AND-GO is used, then we additionally switch
-to the buffer where the process is running."
- (interactive
- (list (or buffer-file-name
- (read-file-name "File to load: " nil nil t))
- current-prefix-arg))
- (comint-check-source file)
- (let ((proc (prog-proc-proc)))
- (prog-proc-send-string proc (prog-proc--call load-cmd file))
- (when and-go (pop-to-buffer (process-buffer proc)))))
-
-(defvar prog-proc--tmp-file nil)
-
-(defun prog-proc-send-region (start end &optional and-go)
- "Send the content of the region to the read-eval-print process.
-START..END delimit the region; AND-GO if non-nil indicate to additionally
-switch to the process's buffer."
- (interactive "r\nP")
- (if (> start end) (let ((tmp end)) (setq end start) (setq start tmp))
- (if (= start end) (error "Nothing to send: the region is empty")))
- (let ((proc (prog-proc-proc))
- (tmp (make-temp-file "emacs-region")))
- (write-region start end tmp nil 'silently)
- (when prog-proc--tmp-file
- (ignore-errors (delete-file (car prog-proc--tmp-file)))
- (set-marker (cdr prog-proc--tmp-file) nil))
- (setq prog-proc--tmp-file (cons tmp (copy-marker start)))
- (prog-proc-send-string proc (prog-proc--call load-cmd tmp))
- (when and-go (pop-to-buffer (process-buffer proc)))))
-
-(defun prog-proc-send-buffer (&optional and-go)
- "Send the content of the current buffer to the read-eval-print process.
-AND-GO if non-nil indicate to additionally switch to the process's buffer."
- (interactive "P")
- (prog-proc-send-region (point-min) (point-max) and-go))
-
-;; FIXME: How 'bout a menu? Now, that's trickier because keymap inheritance
-;; doesn't play nicely with menus!
-
-(define-derived-mode prog-proc-mode prog-mode "Prog-Proc"
- "Major mode for editing source code and interact with an interactive loop."
- )
-
-;;; Extended comint-mode for Prog-Proc.
-
-(defun prog-proc-chdir (dir)
- "Change the working directory of the inferior process."
- (interactive "DChange to directory: ")
- (let ((dir (expand-file-name dir))
- (proc (prog-proc-proc)))
- (with-current-buffer (process-buffer proc)
- (prog-proc-send-string proc (prog-proc--call chdir-cmd dir))
- (setq default-directory (file-name-as-directory dir)))))
-
-(defun prog-proc-comint-input-filter-function (str)
- ;; `compile.el' doesn't know that file location info from errors should be
- ;; recomputed afresh (without using stale info from earlier compilations).
- (compilation-forget-errors) ;Has to run before compilation-fake-loc.
- (if prog-proc--tmp-file
- (compilation-fake-loc (cdr prog-proc--tmp-file)
- (car prog-proc--tmp-file)))
- str)
-
-(define-derived-mode prog-proc-comint-mode comint-mode "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
- ;; since the child-mode might want to add rules to
- ;; compilation-error-regexp-alist.
- (add-hook 'after-change-major-mode-hook #'compilation-minor-mode nil t)
- ;; The keymap of compilation-minor-mode is too unbearable, so we
- ;; just can't use the minor-mode if we can't override the map.
- ;; Eliminate compilation-minor-mode's map.
- (let ((map (make-sparse-keymap)))
- (dolist (keys '([menu-bar] [follow-link]))
- ;; Preserve some of the bindings.
- (define-key map keys (lookup-key compilation-minor-mode-map keys)))
- (add-to-list 'minor-mode-overriding-map-alist
- (cons 'compilation-minor-mode map)))
-
- (add-hook 'comint-input-filter-functions
- #'prog-proc-comint-input-filter-function nil t))
-
-(defvar prog-proc-compile-command nil
- "The command used by default by `prog-proc-compile'.
-See also `prog-proc-compile-commands-alist'.")
-
-(defvar prog-proc-compile-commands-alist nil
- "Commands used by default by `prog-proc-compile'.
-Each command is associated with its \"main\" file.
-It is perfectly OK to associate several files with a command or several
-commands with the same file.")
-
-(defun prog-proc-compile (command &optional and-go)
- "Pass COMMAND to the read-eval-loop process to compile the current file.
-
-You can then use the command \\[next-error] to find the next error message
-and move to the source code that caused it.
-
-Interactively, prompts for the command if `compilation-read-command' is
-non-nil. With prefix arg, always prompts.
-
-Prefix arg AND-GO also means to switch to the read-eval-loop buffer afterwards."
- (interactive
- (let* ((dir default-directory)
- (cmd "cd \"."))
- ;; Look for files to determine the default command.
- (while (and (stringp dir)
- (progn
- (dolist (cf (prog-proc--prop compile-commands-alist))
- (when (file-exists-p (expand-file-name (cdr cf) dir))
- (setq cmd (concat cmd "\"; " (car cf)))
- (return nil)))
- (not cmd)))
- (let ((newdir (file-name-directory (directory-file-name dir))))
- (setq dir (unless (equal newdir dir) newdir))
- (setq cmd (concat cmd "/.."))))
- (setq cmd
- (cond
- ((local-variable-p 'prog-proc-compile-command)
- prog-proc-compile-command)
- ((string-match "^\\s-*cd\\s-+\"\\.\"\\s-*;\\s-*" cmd)
- (substring cmd (match-end 0)))
- ((string-match "^\\s-*cd\\s-+\"\\(\\./\\)" cmd)
- (replace-match "" t t cmd 1))
- ((string-match ";" cmd) cmd)
- (t prog-proc-compile-command)))
- ;; code taken from compile.el
- (list (if (or compilation-read-command current-prefix-arg)
- (read-from-minibuffer "Compile command: "
- cmd nil nil '(compile-history . 1))
- cmd))))
- ;; ;; now look for command's file to determine the directory
- ;; (setq dir default-directory)
- ;; (while (and (stringp dir)
- ;; (dolist (cf (prog-proc--prop compile-commands-alist) t)
- ;; (when (and (equal cmd (car cf))
- ;; (file-exists-p (expand-file-name (cdr cf) dir)))
- ;; (return nil))))
- ;; (let ((newdir (file-name-directory (directory-file-name dir))))
- ;; (setq dir (unless (equal newdir dir) newdir))))
- ;; (setq dir (or dir default-directory))
- ;; (list cmd dir)))
- (set (make-local-variable 'prog-proc-compile-command) command)
- (save-some-buffers (not compilation-ask-about-save) nil)
- (let ((dir default-directory))
- (when (string-match "^\\s-*cd\\s-+\"\\([^\"]+\\)\"\\s-*;" command)
- (setq dir (match-string 1 command))
- (setq command (replace-match "" t t command)))
- (setq dir (expand-file-name dir))
- (let ((proc (prog-proc-proc)))
- (with-current-buffer (process-buffer proc)
- (setq default-directory dir)
- (prog-proc-send-string
- proc (concat (prog-proc--call chdir-cmd dir) "\n" command))
- (when and-go (pop-to-buffer (process-buffer proc)))))))
-
-(provide 'prog-proc)
-;;; prog-proc.el ends here
;;; sml-mode.el --- Major mode for editing (Standard) ML -*- lexical-binding: t; coding: utf-8 -*-
-;; Copyright (C) 1999,2000,2004,2007,2010-2012 Stefan Monnier
-;; Copyright (C) 1994-1997 Matthew J. Morley
-;; Copyright (C) 1989 Lars Bo Nielsen
+;; Copyright (C) 1989,1999,2000,2004,2007,2010-2012 Free Software Foundation, Inc.
-;; Author: Lars Bo Nielsen
+;; Maintainer: (Stefan Monnier) <monnier@iro.umontreal.ca>
+;; Version: 6.0
+;; Keywords: SML
+;; Authors of previous versions:
+;; Lars Bo Nielsen
;; Olin Shivers
;; Fritz Knabe (?)
;; Steven Gilmore (?)
-;; Matthew Morley <mjm@scs.leeds.ac.uk> (aka <matthew@verisity.com>)
-;; Matthias Blume <blume@cs.princeton.edu> (aka <blume@kurims.kyoto-u.ac.jp>)
+;; Matthew Morley <mjm@scs.leeds.ac.uk>
+;; Matthias Blume <blume@cs.princeton.edu>
;; (Stefan Monnier) <monnier@iro.umontreal.ca>
-;; Maintainer: (Stefan Monnier) <monnier@iro.umontreal.ca>
-;; Keywords: SML
-;; This file is not part of GNU Emacs, but it is distributed under the
-;; same conditions.
+;; This file is part of GNU Emacs.
-;; 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, or (at
-;; your option) any later version.
+;; GNU Emacs 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.
+;; GNU Emacs 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 GNU Emacs; see the file COPYING. If not, write to the
-;; Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
-;;; HISTORY
-
-;; Still under construction: History obscure, needs a biographer as
-;; well as a M-x doctor. Change Log on request.
-
-;; Hacked by Olin Shivers for comint from Lars Bo Nielsen's sml.el.
-
-;; Hacked by Matthew Morley to incorporate Fritz Knabe's hilite and
-;; font-lock patterns, some of Steven Gilmore's (reduced) easy-menus,
-;; and numerous bugs and bug-fixes.
-
-;;; DESCRIPTION
-
-;; See accompanying info file: sml-mode.info
-
-;;; FOR YOUR .EMACS FILE
-
-;; If sml-mode.el lives in some non-standard directory, you must tell
-;; emacs where to get it. This may or may not be necessary:
-
-;; (add-to-list 'load-path "~jones/lib/emacs/")
-
-;; Then to access the commands autoload sml-mode with that command:
-
-;; (load "sml-mode-startup")
-
-;; sml-mode-hook is run whenever a new sml-mode buffer is created.
-
-;; Finally, there are inferior-sml-{mode,load}-hooks -- see comments
-;; in sml-proc.el. For much more information consult the mode's *info*
-;; tree.
+;; A major mode to edit Standard ML (SML) code.
+;; Provides the following features, among others:
+;; - Indentation.
+;; - Syntax highlighting.
+;; - Prettified display of ->, =>, fn, ...
+;; - Imenu.
+;; - which-function-mode.
+;; - Skeletons/templates.
+;; - Electric pipe key.
+;; - outline-minor-mode (with some known problems).
+;; - Interaction with a read-eval-print loop.
;;; Code:
(eval-when-compile (require 'cl))
(require 'smie nil 'noerror)
(require 'electric)
-(require 'prog-proc)
(defgroup sml ()
"Editing SML code."
"Run upon entering `sml-mode'.
This is a good place to put your preferred key bindings.")
-;;; Autoload functions -- no-doc is another idea cribbed from AucTeX!
-;; FIXME-copyright: probably include sml-proc.el in sml-mode.el.
-(let ((sml-no-doc
- "This function is part of sml-proc, and has not yet been loaded.
-Full documentation will be available after autoloading the function."))
-
- (autoload 'sml-compile "sml-proc" sml-no-doc t)
- (autoload 'sml-load-file "sml-proc" sml-no-doc t)
- (autoload 'switch-to-sml "sml-proc" sml-no-doc t)
- (autoload 'sml-send-region "sml-proc" sml-no-doc t)
- (autoload 'sml-send-buffer "sml-proc" sml-no-doc t))
-
;; font-lock setup
(defvar sml-outline-regexp
(easy-menu-define sml-mode-menu sml-mode-map "Menu used in `sml-mode'."
'("SML"
- ("Process" ;FIXME-copyright.
- ["Start default ML compiler" run-sml t]
+ ("Process"
+ ["Start SML repl" run-sml t]
["-" nil nil]
- ["run CM.make" sml-compile t]
- ["load ML source file" sml-load-file t]
- ["switch to ML buffer" switch-to-sml t]
+ ["Compile the project" sml-prog-proc-compile t]
+ ["Send file" sml-prog-proc-load-file t]
+ ["Switch to SML repl" sml-prog-proc-switch-to t]
["--" nil nil]
- ["send buffer contents" sml-send-buffer t]
- ["send region" sml-send-region t]
- ["send function" sml-send-function t]
- ["goto next error" next-error (featurep 'sml-proc)]
- ["---" nil nil]
- ["Help for Inferior ML" (describe-function 'inferior-sml-mode)
- :active (featurep 'sml-proc)])
- ["insert SML form" sml-insert-form t] ;FIXME-copyright.
+ ["Send buffer" sml-prog-proc-send-buffer t]
+ ["Send region" sml-prog-proc-send-region t]
+ ["Send function" sml-send-function t]
+ ["Goto next error" next-error t])
+ ["Insert SML form" sml-insert-form t]
("Forms" :filter sml-forms-menu)
- ("Format/Mode Variables" ;FIXME-copyright.
- ["indent region" indent-region t]
- ["outdent" sml-back-to-outer-indent t]
- ;; ["-" nil nil]
- ;; ["set indent-level" sml-indent-level t]
- ;; ["set pipe-indent" sml-pipe-indent t]
- ;; ["--" nil nil]
- ;; ["toggle type-of-indent" sml-type-of-indent t]
- ;; ["toggle nested-if-indent" sml-nested-if-indent t]
- )
+ ["Indent region" indent-region t]
+ ["Outdent line" sml-back-to-outer-indent t]
["-----" nil nil]
- ["SML mode help (brief)" describe-mode t])) ;FIXME-copyright.
+ ["Customize SML-mode" (customize-group 'sml) t]
+ ["SML mode help" describe-mode t]))
;;
;; Regexps
(modify-syntax-entry ?\\ "." st)
(modify-syntax-entry ?* "." st)
st)
- "Syntax table for text-properties")
+ "Syntax table for text-properties.")
(defconst sml-font-lock-syntactic-keywords
`(("^\\s-*\\(\\\\\\)" (1 ',sml-syntax-prop-table))))
alist)))))
alist))
-;;; Prog-Proc support. ;FIXME-copyright.
+;;; Generic prog-proc interaction.
+
+(require 'comint)
+(require 'compile)
+
+(defvar sml-prog-proc-mode-map
+ (let ((map (make-sparse-keymap)))
+ (define-key map [?\C-c ?\C-l] 'sml-prog-proc-load-file)
+ (define-key map [?\C-c ?\C-c] 'sml-prog-proc-compile)
+ (define-key map [?\C-c ?\C-z] 'sml-prog-proc-switch-to)
+ (define-key map [?\C-c ?\C-r] 'sml-prog-proc-send-region)
+ (define-key map [?\C-c ?\C-b] 'sml-prog-proc-send-buffer)
+ ;; FIXME: Add
+ ;; (define-key map [?\M-C-x] 'sml-prog-proc-send-defun)
+ ;; (define-key map [?\C-x ?\C-e] 'sml-prog-proc-send-last-sexp)
+ ;; FIXME: Add menu. Now, that's trickier because keymap inheritance
+ ;; doesn't play nicely with menus!
+ map)
+ "Keymap for `sml-prog-proc-mode'.")
+
+(defvar sml-prog-proc--buffer nil
+ "The inferior-process buffer to which to send code.")
+(make-variable-buffer-local 'sml-prog-proc--buffer)
+
+(defstruct (sml-prog-proc-descriptor
+ (:constructor sml-prog-proc-make)
+ (:predicate nil)
+ (:copier nil))
+ (name nil :read-only t)
+ (run nil :read-only t)
+ (load-cmd nil :read-only t)
+ (chdir-cmd nil :read-only t)
+ (command-eol "\n" :read-only t)
+ (compile-commands-alist nil :read-only t))
+
+(defvar sml-prog-proc-descriptor nil
+ "Struct containing the various functions to create a new process, ...")
+
+(defmacro sml-prog-proc--prop (prop)
+ `(,(intern (format "sml-prog-proc-descriptor-%s" prop))
+ (or sml-prog-proc-descriptor
+ ;; FIXME: Look for available ones and pick one.
+ (error "Not a `sml-prog-proc' buffer"))))
+(defmacro sml-prog-proc--call (method &rest args)
+ `(funcall (sml-prog-proc--prop ,method) ,@args))
+
+;; The inferior process and his buffer are basically interchangeable.
+;; Currently the code takes sml-prog-proc--buffer as the main reference,
+;; but all users should either use sml-prog-proc-proc or sml-prog-proc-buffer
+;; to find the info.
+
+(defun sml-prog-proc-proc ()
+ "Return the inferior process for the code in current buffer."
+ (or (and (buffer-live-p sml-prog-proc--buffer)
+ (get-buffer-process sml-prog-proc--buffer))
+ (when (derived-mode-p 'sml-prog-proc-mode 'sml-prog-proc-comint-mode)
+ (setq sml-prog-proc--buffer (current-buffer))
+ (get-buffer-process sml-prog-proc--buffer))
+ (let ((ppd sml-prog-proc-descriptor)
+ (buf (sml-prog-proc--call run)))
+ (with-current-buffer buf
+ (if (and ppd (null sml-prog-proc-descriptor))
+ (set (make-local-variable 'sml-prog-proc-descriptor) ppd)))
+ (setq sml-prog-proc--buffer buf)
+ (get-buffer-process sml-prog-proc--buffer))))
+
+(defun sml-prog-proc-buffer ()
+ "Return the buffer of the inferior process."
+ (process-buffer (sml-prog-proc-proc)))
+
+(defun sml-prog-proc-switch-to ()
+ "Switch to the buffer running the read-eval-print process."
+ (pop-to-buffer (sml-prog-proc-buffer)))
+
+(defun sml-prog-proc-send-string (proc str)
+ "Send command STR to PROC, with an EOL terminator appended."
+ (with-current-buffer (process-buffer proc)
+ ;; FIXME: comint-send-string does not pass the string through
+ ;; comint-input-filter-function, so we have to do it by hand.
+ ;; Maybe we should insert the command into the buffer and then call
+ ;; comint-send-input?
+ (sml-prog-proc-comint-input-filter-function nil)
+ (comint-send-string proc (concat str (sml-prog-proc--prop command-eol)))))
+
+(defun sml-prog-proc-load-file (file &optional and-go)
+ "Load FILE into the read-eval-print process.
+FILE is the file visited by the current buffer.
+If prefix argument AND-GO is used, then we additionally switch
+to the buffer where the process is running."
+ (interactive
+ (list (or buffer-file-name
+ (read-file-name "File to load: " nil nil t))
+ current-prefix-arg))
+ (comint-check-source file)
+ (let ((proc (sml-prog-proc-proc)))
+ (sml-prog-proc-send-string proc (sml-prog-proc--call load-cmd file))
+ (when and-go (pop-to-buffer (process-buffer proc)))))
+
+(defvar sml-prog-proc--tmp-file nil)
+
+(defun sml-prog-proc-send-region (start end &optional and-go)
+ "Send the content of the region to the read-eval-print process.
+START..END delimit the region; AND-GO if non-nil indicate to additionally
+switch to the process's buffer."
+ (interactive "r\nP")
+ (if (> start end) (let ((tmp end)) (setq end start) (setq start tmp))
+ (if (= start end) (error "Nothing to send: the region is empty")))
+ (let ((proc (sml-prog-proc-proc))
+ (tmp (make-temp-file "emacs-region")))
+ (write-region start end tmp nil 'silently)
+ (when sml-prog-proc--tmp-file
+ (ignore-errors (delete-file (car sml-prog-proc--tmp-file)))
+ (set-marker (cdr sml-prog-proc--tmp-file) nil))
+ (setq sml-prog-proc--tmp-file (cons tmp (copy-marker start)))
+ (sml-prog-proc-send-string proc (sml-prog-proc--call load-cmd tmp))
+ (when and-go (pop-to-buffer (process-buffer proc)))))
+
+(defun sml-prog-proc-send-buffer (&optional and-go)
+ "Send the content of the current buffer to the read-eval-print process.
+AND-GO if non-nil indicate to additionally switch to the process's buffer."
+ (interactive "P")
+ (sml-prog-proc-send-region (point-min) (point-max) and-go))
+
+(define-derived-mode sml-prog-proc-mode prog-mode "Sml-Prog-Proc"
+ "Major mode for editing source code and interact with an interactive loop."
+ )
+
+;;; Extended comint-mode for Sml-Prog-Proc.
+
+(defun sml-prog-proc-chdir (dir)
+ "Change the working directory of the inferior process to DIR."
+ (interactive "DChange to directory: ")
+ (let ((dir (expand-file-name dir))
+ (proc (sml-prog-proc-proc)))
+ (with-current-buffer (process-buffer proc)
+ (sml-prog-proc-send-string proc (sml-prog-proc--call chdir-cmd dir))
+ (setq default-directory (file-name-as-directory dir)))))
+
+(defun sml-prog-proc-comint-input-filter-function (str)
+ ;; `compile.el' doesn't know that file location info from errors should be
+ ;; recomputed afresh (without using stale info from earlier compilations).
+ (compilation-forget-errors) ;Has to run before compilation-fake-loc.
+ (if (and sml-prog-proc--tmp-file (marker-buffer (cdr sml-prog-proc--tmp-file)))
+ (compilation-fake-loc (cdr sml-prog-proc--tmp-file)
+ (car sml-prog-proc--tmp-file)))
+ str)
+
+(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
+ ;; since the child-mode might want to add rules to
+ ;; compilation-error-regexp-alist.
+ (add-hook 'after-change-major-mode-hook #'compilation-minor-mode nil t)
+ ;; The keymap of compilation-minor-mode is too unbearable, so we
+ ;; need to hide most of the bindings.
+ (let ((map (make-sparse-keymap)))
+ (dolist (keys '([menu-bar] [follow-link]))
+ ;; Preserve some of the bindings.
+ (define-key map keys (lookup-key compilation-minor-mode-map keys)))
+ (add-to-list 'minor-mode-overriding-map-alist
+ (cons 'compilation-minor-mode map)))
+
+ (add-hook 'comint-input-filter-functions
+ #'sml-prog-proc-comint-input-filter-function nil t))
+
+(defvar sml-prog-proc--compile-command nil
+ "The command used by default by `sml-prog-proc-compile'.")
+
+(defun sml-prog-proc-compile (command &optional and-go)
+ "Pass COMMAND to the read-eval-loop process to compile the current file.
+
+You can then use the command \\[next-error] to find the next error message
+and move to the source code that caused it.
+
+Interactively, prompts for the command if `compilation-read-command' is
+non-nil. With prefix arg, always prompts.
+
+Prefix arg AND-GO also means to switch to the read-eval-loop buffer afterwards."
+ (interactive
+ (let* ((dir default-directory)
+ (cmd "cd \"."))
+ ;; Look for files to determine the default command.
+ (while (and (stringp dir)
+ (progn
+ (dolist (cf (sml-prog-proc--prop compile-commands-alist))
+ (when (file-exists-p (expand-file-name (cdr cf) dir))
+ (setq cmd (concat cmd "\"; " (car cf)))
+ (return nil)))
+ (not cmd)))
+ (let ((newdir (file-name-directory (directory-file-name dir))))
+ (setq dir (unless (equal newdir dir) newdir))
+ (setq cmd (concat cmd "/.."))))
+ (setq cmd
+ (cond
+ ((local-variable-p 'sml-prog-proc--compile-command)
+ sml-prog-proc--compile-command)
+ ((string-match "^\\s-*cd\\s-+\"\\.\"\\s-*;\\s-*" cmd)
+ (substring cmd (match-end 0)))
+ ((string-match "^\\s-*cd\\s-+\"\\(\\./\\)" cmd)
+ (replace-match "" t t cmd 1))
+ ((string-match ";" cmd) cmd)
+ (t sml-prog-proc--compile-command)))
+ ;; code taken from compile.el
+ (list (if (or compilation-read-command current-prefix-arg)
+ (read-from-minibuffer "Compile command: "
+ cmd nil nil '(compile-history . 1))
+ cmd))))
+ ;; ;; now look for command's file to determine the directory
+ ;; (setq dir default-directory)
+ ;; (while (and (stringp dir)
+ ;; (dolist (cf (sml-prog-proc--prop compile-commands-alist) t)
+ ;; (when (and (equal cmd (car cf))
+ ;; (file-exists-p (expand-file-name (cdr cf) dir)))
+ ;; (return nil))))
+ ;; (let ((newdir (file-name-directory (directory-file-name dir))))
+ ;; (setq dir (unless (equal newdir dir) newdir))))
+ ;; (setq dir (or dir default-directory))
+ ;; (list cmd dir)))
+ (set (make-local-variable 'sml-prog-proc--compile-command) command)
+ (save-some-buffers (not compilation-ask-about-save) nil)
+ (let ((dir default-directory))
+ (when (string-match "^\\s-*cd\\s-+\"\\([^\"]+\\)\"\\s-*;" command)
+ (setq dir (match-string 1 command))
+ (setq command (replace-match "" t t command)))
+ (setq dir (expand-file-name dir))
+ (let ((proc (sml-prog-proc-proc))
+ (eol (sml-prog-proc--prop command-eol)))
+ (with-current-buffer (process-buffer proc)
+ (setq default-directory dir)
+ (sml-prog-proc-send-string
+ proc (concat (sml-prog-proc--call chdir-cmd dir)
+ ;; Strip the newline, to avoid adding a prompt.
+ (if (string-match "\n\\'" eol)
+ (replace-match " " t t eol) eol)
+ command))
+ (when and-go (pop-to-buffer (process-buffer proc)))))))
+
+
+;;; SML Sml-Prog-Proc support.
(defcustom sml-program-name "sml"
- "Program to run as Standard ML read-eval-print loop."
+ "Program to run as Standard SML read-eval-print loop."
:type 'string)
(defcustom sml-default-arg ""
:type 'string)
(defcustom sml-config-file "~/.smlproc.sml"
- "File that should be fed to the ML process when started."
+ "File that should be fed to the SML process when started."
:type 'string)
(defcustom sml-prompt-regexp "^[-=>#] *"
- "Regexp used to recognise prompts in the inferior ML process."
+ "Regexp used to recognise prompts in the inferior SML process."
:type 'regexp)
(defcustom sml-compile-commands-alist
- '(("CMB.make();" . "all-files.cm")
- ("CMB.make();" . "pathconfig")
- ("CM.make();" . "sources.cm")
- ("use \"load-all\";" . "load-all"))
- "Commands used by default by `sml-prog-proc-compile'.
+ '(("CMB.make()" . "all-files.cm")
+ ("CMB.make()" . "pathconfig")
+ ("CM.make()" . "sources.cm")
+ ("use \"load-all\"" . "load-all"))
+ "Commands used by default by `sml-sml-prog-proc-compile'.
Each command is associated with its \"main\" file.
It is perfectly OK to associate several files with a command or several
commands with the same file.")
;; FIXME: Try to auto-detect the process and set those vars accordingly.
(defvar sml-use-command "use \"%s\""
- "Template for loading a file into the inferior ML process.
+ "Template for loading a file into the inferior SML process.
Set to \"use \\\"%s\\\"\" for SML/NJ or Edinburgh ML;
set to \"PolyML.use \\\"%s\\\"\" for Poly/ML, etc.")
(defvar sml-cd-command "OS.FileSys.chDir \"%s\""
- "Command template for changing working directories under ML.
+ "Command template for changing working directories under SML.
Set this to nil if your compiler can't change directories.
The format specifier \"%s\" will be converted into the directory name
See `compilation-error-regexp-alist' for a description of the format.")
(defconst sml-pp-functions
- (prog-proc-make :name "SML"
+ (sml-prog-proc-make :name "SML"
:run (lambda () (call-interactively #'sml-run))
- :load-cmd (lambda (file)
- ;; `sml-use-command' was defined a long time
- ;; ago not to include a final semi-colon.
- (concat (format sml-use-command file) ";"))
- :chdir-cmd (lambda (dir)
- ;; `sml-cd-command' was defined a long time
- ;; ago not to include a final semi-colon.
- (concat (format sml-cd-command dir) ";"))
+ :load-cmd (lambda (file) (format sml-use-command file))
+ :chdir-cmd (lambda (dir) (format sml-cd-command dir))
:compile-commands-alist sml-compile-commands-alist
+ :command-eol ";\n"
))
;; font-lock support
(defun sml--read-run-cmd ()
(list
- (read-string "ML command: " sml-program-name)
+ (read-string "SML command: " sml-program-name)
(if (or current-prefix-arg (> (length sml-default-arg) 0))
(read-string "Any args: " sml-default-arg)
sml-default-arg)
(args (split-string arg))
(file (when (and sml-config-file (file-exists-p sml-config-file))
sml-config-file)))
- ;; and this -- to keep these as defaults even if
+ ;; And this -- to keep these as defaults even if
;; they're set in the mode hooks.
(setq sml-program-name cmd)
(setq sml-default-arg arg)
(goto-char (point-max))
(current-buffer))))
+(defun sml-send-function (&optional and-go)
+ "Send current paragraph to the inferior SML process.
+With a prefix argument AND-GO switch to the repl buffer as well."
+ (interactive "P")
+ (save-excursion
+ (sml-mark-function)
+ (sml-prog-proc-send-region (point) (mark)))
+ (if and-go (sml-prog-proc-switch-to)))
+
(defvar inferior-sml-mode-map
(let ((map (make-sparse-keymap)))
(set-keymap-parent map comint-mode-map)
(define-key map "\C-c\C-l" 'sml-load-file)
(define-key map "\t" 'completion-at-point)
map)
- "Keymap for inferior-sml mode")
+ "Keymap for inferior-sml mode.")
(declare-function smerge-refine-subst "smerge-mode"
(smerge-refine-subst b1 e1 b2 e2
'((face . smerge-refined-change))))))))))
-(define-derived-mode inferior-sml-mode prog-proc-comint-mode "Inferior-SML"
- "Major mode for interacting with an inferior ML process.
+(define-derived-mode inferior-sml-mode sml-prog-proc-comint-mode "Inferior-SML"
+ "Major mode for interacting with an inferior SML process.
The following commands are available:
\\{inferior-sml-mode-map}
-An ML process can be fired up (again) with \\[sml].
+An SML process can be fired up (again) with \\[sml].
Customisation: Entry to this mode runs the hooks on `comint-mode-hook'
and `inferior-sml-mode-hook' (in that order).
Variables controlling behaviour of this mode are
`sml-program-name' (default \"sml\")
- Program to run as ML.
+ Program to run as SML.
`sml-use-command' (default \"use \\\"%s\\\"\")
- Template for loading a file into the inferior ML process.
+ Template for loading a file into the inferior SML process.
`sml-cd-command' (default \"System.Directory.cd \\\"%s\\\"\")
- ML command for changing directories in ML process (if possible).
+ SML command for changing directories in SML process (if possible).
`sml-prompt-regexp' (default \"^[\\-=] *\")
- Regexp used to recognise prompts in the inferior ML process.
+ Regexp used to recognise prompts in the inferior SML process.
-You can send text to the inferior ML process from other buffers containing
-ML source.
- `switch-to-sml' switches the current buffer to the ML process buffer.
- `sml-send-function' sends the current *paragraph* to the ML process.
- `sml-send-region' sends the current region to the ML process.
+You can send text to the inferior SML process from other buffers containing
+SML source.
+ `switch-to-sml' switches the current buffer to the SML process buffer.
+ `sml-send-function' sends the current *paragraph* to the SML process.
+ `sml-send-region' sends the current region to the SML process.
Prefixing the sml-send-<whatever> commands with \\[universal-argument]
- causes a switch to the ML process buffer after sending the text.
+ causes a switch to the SML process buffer after sending the text.
For information on running multiple processes in multiple buffers, see
documentation for variable `sml-buffer'.
(defvar comment-quote-nested)
;;;###autoload
-(define-derived-mode sml-mode prog-proc-mode "SML"
+(define-derived-mode sml-mode sml-prog-proc-mode "SML"
"\\<sml-mode-map>Major mode for editing Standard ML code.
This mode runs `sml-mode-hook' just before exiting.
See also (info \"(sml-mode)Top\").
\\{sml-mode-map}"
- (set (make-local-variable 'prog-proc-functions) sml-pp-functions)
+ (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)
(push-mark nil t t)
(goto-char beg)))))
-(defun sml-back-to-outer-indent () ;FIXME-copyright.
+(defun sml-back-to-outer-indent ()
"Unindents to the next outer level of indentation."
(interactive)
(save-excursion
- (beginning-of-line)
- (skip-chars-forward "\t ")
- (let ((start-column (current-column))
- (indent (current-column)))
- (if (> start-column 0)
- (progn
- (save-excursion
- (while (>= indent start-column)
- (setq indent (if (re-search-backward "^[^\n]" nil t)
- (current-indentation)
- 0))))
- (backward-delete-char-untabify (- start-column indent)))))))
+ (forward-line 0)
+ (let ((start-column (current-indentation))
+ indent)
+ (when (> start-column 0)
+ (save-excursion
+ (while (>= (setq indent
+ (if (re-search-backward "^[ \t]*[^\n\t]" nil t)
+ (current-indentation)
+ 0))
+ start-column))
+ (skip-chars-forward " \t")
+ (let ((pos (point)))
+ (move-to-column start-column)
+ (when (re-search-backward " \\([^ \t\n]\\)" pos t)
+ (goto-char (match-beginning 1))
+ (setq indent (current-column)))))
+ (indent-line-to indent)))))
(defun sml-find-matching-starter (syms)
(let ((halfsexp nil)
If 'sml-form-NAME' is a function it takes no arguments and should
insert the template at point\; if this is a command it may accept any
sensible interactive call arguments\; keyboard macros can't take
-arguments at all. Apropos keyboard macros, see `name-last-kbd-macro'
-and `sml-addto-forms-alist'.
+arguments at all.
`sml-forms-alist' understands let, local, case, abstype, datatype,
signature, structure, and functor by default.")
the corresponding form is inserted."
(interactive)
(let ((abbrev-mode (not abbrev-mode))
- (last-command-event ?\ )
+ (last-command-event ?\s)
;; 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) ;FIXME-copyright.
- "Interactive short-cut to insert the NAME common ML form.
+(defun sml-insert-form (name newline)
+ "Interactive short-cut to insert the NAME common SML form.
If a prefix argument is given insert a NEWLINE and indent first, or
just move to the proper indentation if the line is blank\; otherwise
insert at point (which forces indentation to current column).
(f (funcall f))
(t (error "Undefined SML form: %s" name)))))
-;; See also macros.el in emacs lisp dir.
-
-(defun sml-addto-forms-alist (name) ;FIXME-copyright.
- "Assign a name to the last keyboard macro defined.
-Argument NAME is transmogrified to sml-form-NAME which is the symbol
-actually defined.
-
-The symbol's function definition becomes the keyboard macro string.
-
-If that works, NAME is added to `sml-forms-alist' so you'll be able to
-reinvoke the macro through \\[sml-insert-form]. You might want to save
-the macro to use in a later editing session -- see `insert-kbd-macro'
-and add these macros to your .emacs file.
-
-See also `edit-kbd-macro' which is bound to \\[edit-kbd-macro]."
- (interactive "sName for last kbd macro (\"sml-form-\" will be added): ")
- (when (string= name "") (error "No command name given"))
- (let ((fsym (intern (concat "sml-form-" name))))
- (name-last-kbd-macro fsym)
- (message "Macro bound to %s" fsym)
- (add-to-list 'sml-forms-alist (cons name fsym))))
-
;;;
;;; MLton support
;;;
(add-to-list 'compilation-error-regexp-alist x)))
(defun sml-mlton-typecheck (mainfile)
- "typecheck using MLton."
+ "Typecheck using MLton.
+MAINFILE is the top level file of the project."
(interactive
(list (if (and sml-mlton-mainfile (not current-prefix-arg))
sml-mlton-mainfile
;;;###autoload
(define-derived-mode sml-cm-mode fundamental-mode "SML-CM"
"Major mode for SML/NJ's Compilation Manager configuration files."
- (local-set-key "\C-c\C-c" 'sml-compile)
+ (set (make-local-variable 'sml-prog-proc-descriptor) sml-pp-functions)
(set (make-local-variable 'font-lock-defaults)
'(sml-cm-font-lock-keywords nil t nil nil)))
@code{sml-insert-form}, described below.
@end deffn
-@deffn Command sml-electric-semi
-Key: @kbd{;}
-@kindex @kbd{;}
-
-Just inserts a semi-colon, usually. The behaviour of this command is
-governed by the variable @code{sml-electric-semi-mode}.
-@end deffn
-
-
-@defvr Variable sml-electric-semi-mode
-Default: @code{nil}
-
-If this variable is @code{nil}, @code{sml-electric-semi} just inserts a
-semi-colon, otherwise it inserts a semi-colon and a newline, and indents
-the newline for SML.
-@end defvr
-
-
@deffn Command sml-insert-form
Key: @kbd{C-c @key{RET}}
@kindex @kbd{C-c @key{RET}}
(setq sml-indent-level 2) ; conserve on horizontal space
(setq words-include-escape t) ; \ loses word break status
(setq indent-tabs-mode nil)) ; never ever indent with tabs
-(add-hook 'sml-mode-hook 'my-sml-mode-hook)
+(add-hook 'sml-mode-hook #'my-sml-mode-hook)
@end lisp
@noindent
The body of @code{my-sml-mode-hook} is a sequence of assignments. In this