[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Now SML mode provides just a few additional editing commands. Most of the work has gone into implementing the indentation algorithm which, if you think about it, has to be complicated for a language like ML. See section Indentation Defaults, for details on how to control some of the behaviour of the indentation algorithm. Principal goodies are the `electric pipe' feature, and the ability to insert common SML forms (macros or templates).
4.1 On entering SML mode | ||
4.2 Automatic indentation | Prettying SML text | |
4.3 Electric features | Templates and electric keys | |
4.4 Indentation defaults | Variables controlling indentation |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Emacs is all hooks of course. A hook is a variable: if the variable is non-nil it binds a list of Emacs Lisp functions to be run in some order (usually left to right). You can customise SML mode with these hooks:
nil
This is run every time a new SML mode buffer is created (or if you type M-x sml-mode). This is one place to put your preferred key bindings. See section 6. Configuration Summary, for some examples.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
ML is a complicated language to parse, let alone compile. The indentation algorithm is a little wooden (for some tastes), and the best advice is not to fight it! There are several variables that can be adjusted to control the indentation algorithm (see section Customising SML Mode, below).
This command indents the current line. If you set the indentation of the
previous line by hand, indent-for-tab-command
will indent relative to
this setting.
Indent the current region. Be patient if the region is large (like the whole buffer).
Unindents the line to the next outer level of indentation.
Further indentation commands that Emacs provides (generically, for all modes) that you may like to recall:
On LFD by default. Insert a newline, then indent according to the major mode. See section `Indentation for Programs' in The Emacs Editor Manual, for details.
On C-x TAB by default. Moves all lines in the region right by its argument (left, for negative arguments). See section `Indentation' in The Emacs Editor Manual.
On M-; by default. Indent this line's comment to comment column, or insert an empty comment. See section `Comment Commands' in The Emacs Editor Manual.
On M-LFD by default. Break line at point and indent, continuing comment if within one. See section `Multi-Line Comments' in The Emacs Editor Manual.
As with other language modes, M-; gives you a comment at the end
of the current line. The column where the comment starts is determined
by the variable comment-column
---default is 40, but it can be
changed with set-comment-column
(on C-x ; by default).
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Electric keys are generally pretty irritating, so those provided by SML mode are fairly muted. The only truly electric key is ;, and this has to be enabled to take effect.
When the point is in a `case' statement this opens a new line, indents
and inserts | =>
leaving point just before the double arrow; if
the enclosing construct is a `fun' declaration, the newline is indented
and the function name copied at the appropriate column. Generally, try
it whenever a |
is wanted--you'll like it!
When the point is after a keyword like `let', this inserts the
corresponding predefined skeleton if one exists. Else it just inserts a
space. Another way to insert those skeletons is to use
sml-insert-form
, described below.
Just inserts a semi-colon, usually. The behaviour of this command is
governed by the variable sml-electric-semi-mode
.
nil
If this variable is nil
, sml-electric-semi
just inserts a
semi-colon, otherwise it inserts a semi-colon and a newline, and indents
the newline for SML.
Interactive short-cut to insert common ML forms (a.k.a. macros, or templates). Recognised forms are `let', `local', `case', `abstype', `datatype', `signature', `structure', and `functor'. Except for `let' and `local', these will prompt for appropriate parameters like functor name and signature, etc.. This command prompts in the mini-buffer, with completion.
By default C-c RET will insert at point, with the indentation of the current column; if you give a prefix argument (i.e., C-u C-c RET) the command will insert a newline first, indent, and then insert the template.
sml-insert-form
is also extensible: see 6. Configuration Summary for
further details.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Several variables try to control the indentation algorithm and other features of SML mode. Most of them are still in flux so they are not described here yet. If the default values are not acceptable you can set these variables permanently in your `.emacs' file. See section 6. Configuration Summary, for details and examples.
4
This variable controls the block indentation level.
[ << ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated by XEmacs shared group account on December, 19 2009
using texi2html 1.65.