SMLMode The package, sml-mode, is an Emacs mode that allows editing SML code, and running an SML interpreter as a subprocess of Emacs. Actually, it can use any standard-compliant interpreter, like SML of New Jersey, and MoscowML. Oct 08, 2018  Major mode for editing (Standard) ML. Contribute to emacsmirror/sml-mode development by creating an account on GitHub.

Configuring GNU Emacs to run SML/NJ

To configure GNU Emacs to run SML/NJ, copy the Elisp files for SML mode from/afs/andrew/course/15/212sp/lib/elisp to your local machine,and add the following lines to the end of your .emacs file(these lines can also be found in the file emacs.additions):

On Windows machines you will probably wish to replace the last twolines above with lines similar to the following:

The precise pathnames in these last three lines depend on where youhave installed the various pieces of the system. Theload-path definition assumes that the Elisp files were copiedto the directory c:smlnjesml. Thesml-program-name definition assumes that the SML/NJ systemwas installed underneath the directory c:smlnj, invokeable bythe indicated .bat file. The sml-temp-filedefinition assumes that c:temp is a valid directory whereSML/NJ may place temporary files. You may need to experiment a bitwith the exact path names.

If you prefer not to run SML/NJ through GNU Emacs, you may also run itby following links from Window's START menu.

On Andrew, you can start GNU Emacs by typing: emacs

Starting SML within GNU Emacs

To start an SML/NJ within GNU Emacs, one of the following is likely tobe successful (it depends a bit on your particular implementation):

  • Type M-x run-sml at Emacs (and hit ENTER as appropriate, probably twice).
  • Type M-x sml-mode at Emacs (and hit ENTER as appropriate). Then type M-x sml at Emacs (and hit ENTER as appropriate).
  • Read in a file with extension .sml, then type M-x sml at Emacs (and hit ENTER as appropriate).
When GNU Emacs starts SML it may be in a different window or in adifferent buffer. Look around.

Using the SML mode for GNU Emacs

When running SML under GNU Emacs, you can have emacs 'use' the currentbuffer or region. The Emacs command C-c C-b sends the currentbuffer to SML/NJ and C-c C-r sends the current Emacs region.You can also have Emacs issue directory change commands with M-xsml-cd.

One of the most useful things Emacs can do for you is to parse errormessages and locate their source. After compiling a file, enter C-c` and Emacs will locate and highlight your first error, as reportedby SML/NJ. You may then locate successive errors by repeating thecommand. Note that if you enter a 'use' directly into SML/NJ(by typing 'use' on the keyboard), Emacs will not know of it,and will continue parsing errors from the previous compile. You can getEmacs back into synch by directing it to ignore all remaining errorswith the M-x sml-skip-errors command.

You may also wish to experiment with the M- command, which begins a newbranch of a case statement or function definition.

A summary of these commands appears below:

Emacs change mode

The default value of major-mode determines the major mode touse for files that do not specify a major mode, and for new bufferscreated with C-x b. Normally, this default value is the symbolfundamental-mode, which specifies Fundamental mode. You canchange this default value via the Customization interface (see Easy Customization), or by adding a line like this to your init file(see Init File):

If the default value of major-mode is nil, the majormode is taken from the previously current buffer.

Specialized major modes often change the meanings of certain keys todo something more suitable for the mode. For instance, programminglanguage modes bind <TAB> to indent the current line according tothe rules of the language (see Indentation). The keys that arecommonly changed are <TAB>, <DEL>, and C-j. Many modesalso define special commands of their own, usually bound to keysequences whose prefix key is C-c (see Keys). Major modescan also alter user options and variables; for instance, programminglanguage modes typically set a buffer-local value for the variablecomment-start, which determines how source code comments aredelimited (see Comments).

To view the documentation for the current major mode, including alist of its key bindings, type C-h m (describe-mode). See Misc Help.

Every major mode, apart from Fundamental mode, defines a modehook, a customizable list of Lisp functions to run each time the modeis enabled in a buffer. See Hooks, for more information abouthooks. Each mode hook is named after its major mode, e.g., Fortranmode has fortran-mode-hook. Furthermore, all text-based majormodes run text-mode-hook, and many programming language modes1 (including all those distributed with Emacs) runprog-mode-hook, prior to running their own mode hooks. Hookfunctions can look at the value of the variable major-mode tosee which mode is actually being entered.

Mode hooks are commonly used to enable minor modes (see Minor Modes). For example, you can put the following lines in your initfile to enable Flyspell minor mode in all text-based major modes(see Spelling), and Eldoc minor mode in Emacs Lisp mode(see Lisp Doc):

Footnotes

Change download folder on mac. [1] More specifically, the modes which are ”derived” fromprog-mode (see Derived Modes).