First install Emacs and install Standard ML of New Jersey:

Now download sml-mode-color.el and inferior-setup.sml to a permanent location on your disk (location to be used later).

Some generic setup for Emacs to put in your “~/.emacs” file 3.

(setq inhibit-startup-message t)        ; dont show the GNU splash screen
(transient-mark-mode t)                 ; show selection from mark
(setq visible-bell 1)                   ; turn off bip warnings
(show-paren-mode t)                     ; turn on highlight paren mode
(fset 'yes-or-no-p 'y-or-n-p)           ; use y and n for questions
(global-font-lock-mode t)               ; enable syntax highlighting
(iswitchb-mode 1)                       ; better buffer switching

To setup Standard ML mode, paste the following into your “~/.emacs” file and update the two lines below the *** marks with the correct paths for your system. Paths should use UNIX-style separators (forward slash), so the Windows path to Standard ML would look like:

"C:/Program Files/SMLNJ/bin/sml.bat"

;; *** set this path to the directory containing "sml-mode-color.el"
(setq sml-mode-dir "/path/to/sml-mode-directory")

;; *** set this path to the sml executable (sml.bat on Windows)
(setq sml-prog-name "/usr/bin/sml")

(add-to-list 'load-path sml-mode-dir)
(autoload 'sml-mode "sml-mode-color" () t)
(add-to-list 'auto-mode-alist '("\\.sml$" . sml-mode))
(add-to-list 'auto-mode-alist '("\\.sig$" . sml-mode))

(add-hook 'sml-mode-hook
   (lambda ()
     (setq indent-tabs-mode nil)
     (setq sml-indent-args 2)
     (local-set-key (kbd "M-SPC") 'just-one-space)))

(add-hook 'sml-shell-hook
   (lambda ()
     (send-string sml-process-name
       (concat "use \""

If you would like more help on using Emacs, you might like this Getting started with GNU Emacs tutorial used as part of dProgSprog.

  1. The MSI installer can be found in the files sections of the SML/NJ download page.

  2. An Emacs bundle for Windows.

  3. To open your .emacs file type C-x C-f (i.e., hit control-x and control-f), then in the mini-buffer type ~/.emacs and hit Enter.