MLton

SML modes

There are a few Emacs modes for SML.

MLB modes

There is a mode for editing ML Basis files.

Completion

  • company-mlton

    company-mlton is a company-mode completion back-end for MLton/Standard ML. It provides completion for Standard ML keywords and for Standard ML (long) identifiers. Candidate completion identifiers for the latter are loaded from a basis file created by mlton using -show-basis file or (#showBasis "file").

Definitions and uses

There is a mode that supports the precise def-use information that MLton can output. It highlights definitions and uses and provides commands for navigation (e.g., jump-to-def, jump-to-next, list-all-refs). It can be handy, for example, for navigating in the MLton compiler source code. See EmacsDefUseMode for further information.

Building in the background

Tired of manually starting/stopping/restarting builds after editing files? Now you don’t have to. See EmacsBgBuildMode for further information.

Error messages

MLton’s error messages are not among those that the Emacs next-error parser natively understands. The easiest way to fix this is to add the following to your .emacs to teach Emacs to recognize MLton’s error messages.

(require 'compile)
(add-to-list 'compilation-error-regexp-alist 'mlton)
(add-to-list 'compilation-error-regexp-alist-alist
             '(mlton
               "^[[:space:]]*\\(\\(?:\\(Error\\)\\|\\(Warning\\)\\|\\(\\(?:\\(?:defn\\|spec\\) at\\)\\|\\(?:escape \\(?:from\\|to\\)\\)\\|\\(?:scoped at\\)\\)\\): \\(.+\\) \\([0-9]+\\)\\.\\([0-9]+\\)\\(?:-\\([0-9]+\\)\\.\\([0-9]+\\)\\)?\\.?\\)$"
               5 (6 . 8) (7 . 9) (3 . 4) 1))