Emacs is an extensible, customizable, self-documenting display editor. Among its many features, it has special modes ("major modes") for editing and running programs of various languages. In particular, there is a major mode, SML-MODE, that provides support for editing and running SML programs.
Emacs will almost certainly be installed on Linux systems. It can also be installed on Mac OS X and Windows machines. Information about installing Emacs is included below.
To run sml (or smlcus — see below) as a child process of Emacs, one types
META-x run-sml RET
Editing a source file whose name ends with .sml (or .sig) causes Emacs to enter the major mode SML-MODE, at which point typing
(or META-x describe-mode RET) will cause a summary of the mode to be printed. One can send the contents of the source file to sml by typing
If sml reports that the source file contains errors, then typing
will cause the cursor of the sml buffer to be positioned at the first error message, and cause the cursor of the source file to be placed at the location of the error itself. The next error can then be examined by typing CTRL-x ` again, and so on.
If the font lock minor mode is turned on, then SML-MODE will display different kinds of lexical items (e.g., strings, comments, keywords) in different colors. To turn font lock mode on in all modes that support it, put the text
in your .emacs file (of your home directory/folder). To only turn on font lock mode in SML-MODE, put the text
(add-hook 'sml-mode-hook 'turn-on-font-lock)
in your .emacs file.
If you want SML-MODE to run smlcus instead of sml, include the following line in your .emacs file:
(setq sml-program-name "smlcus")
If you don't like SML-MODE's indentation conventions, you can turn off automatic indentation by including the following lines in your .emacs file:
(defun my-sml-mode-hook () (local-set-key "\t" 'tab-to-tab-stop)) (add-hook 'sml-mode-hook 'my-sml-mode-hook)
You'll have to exit and re-enter Emacs for the above changes to take effect.
Further information on SML-MODE is available via Emacs's info function (type META-x info RET m smlRET).
In the unlikely case that Emacs isn't already installed on a Linux machine, it can be obtained from www.gnu.org/software/emacs/emacs.html.
The version of Emacs that's distributed with Mac OS X can only be run within a terminal. Instead, you will probably want to install Emacs for Mac OS X.
Emacs will have to be installed on Windows machines. Information about the Windows version of Emacs, including instructions for obtaining and installing Emacs on Windows, can be found at www.gnu.org/software/emacs/windows/ntemacs.html.
The SML-MODE distribution is available as a compressed tarball, as a zip archive and as a directory.
See the file INSTALL for instructions on installing SML-MODE on a machine running Linux, making use of the supplied makefile, and running as root. The makefile will byte-compile the .el files, producing .elc files. The .el and .elc files will go in your site-lisp directory, which will be called something like /usr/share/emacs/site-lisp. Then put the line
in the file site-start.el in the site-lisp directory. The Info file sml-mode.info will be put by the makefile in the Info directory, which will be something like /usr/share/info. The makefile will add a link to this file to the Info top-level node, using the command (modify the directory as needed)
install-info --info-file=sml-mode.info --info-dir=/usr/share/info
The procedure for installing SML-MODE on Mac OS X is very similar to that one for Linux. The difference is that, assuming you've installed Emacs.app, the site-lisp directory will be called
and the info directory will be called
and so the makefile will have to be modified to use these directories. (When the makefile byte-compiles .el files, it will use the terminal version of Emacs, /usr/bin/emacs.)
On a Windows machine, you'll have to install the mode by hand, working by analogy with the installation under Linux. Byte-compile the .el files using the Emacs function byte-compile-file. The .el and .elc files will go in your site-lisp directory, which will be called something like c:\emacs\site-lisp, and the line
should be placed in a file site-start.el in the site-lisp directory. The Info file sml-mode.info should be put in the Info directory, which will be called something like c:\emacs\info. You should edit the file dir of the Info directory so that it includes a pointer to sml-mode.info.