[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The most useful feature of SML mode is that it provides a convenient interface to the compiler. How serious users of ML put up with a teletype interface to the compiler is beyond me... but perhaps there are other interfaces to compilers that require one to part with serious money. Such remarks can quickly become dated--in this case, let's hope so!
Anyway, SML mode provides an interaction mode,
inferior-sml-mode
, where the compiler runs in a separate buffer
in a window or frame of its own. You can use this buffer just like a
terminal, but it's usually more convenient to mark some text in the
SML mode buffer and have Emacs communicate with the sub-process. The
features discussed below are syntax-independent, so they should work
with a wide range of ML-like tools and compilers. See section 5.4 Process defaults, for some hints.
inferior-sml-mode
is a specialisation of the `comint'
package that comes with Emacs and XEmacs.
5.1 Starting the compiler | Commands to run the ML compiler in a buffer | |
5.2 Speaking to the compiler | Sending program fragments to the compiler | |
5.3 Finding errors | Finding reported syntax errors | |
5.4 Process defaults | Setting defaults for process interaction |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Start your favourite ML compiler with the command
M-x run-sml |
This creates a process interaction buffer that inherits some key bindings from SML mode and from `comint' (see section `Shell Mode' in The Emacs Editor Manual). Starting the ML compiler adds some functions to SML mode buffers so that program text can be communicated between editor and compiler (see section 5.2 Speaking to the compiler).
The name of the ML compiler is the first thing you should know how to specify:
"sml"
The program to run as ML. You might need to specify the full path name of the program.
""
Useful for Poly/ML users who may supply a database file, or others who
have wrappers for setting various options around the command to run the
compiler. Moscow ML people might set this to "-P full"
, etc..
The variable sml-program-name
is a string holding the name
of the program as you would type it at the shell. You
can always choose a program different to the default by invoking
C-u M-x run-sml |
With the prefix argument Emacs will prompt for the command name and any command line arguments to pass to the compiler. Thereafter Emacs will use this new name as the default, but for a permanent change you should set this in your `.emacs' with, e.g.:
(setq sml-program-name "nj-sml") |
nil
M-x run-sml runs comint-mode-hook
and
inferior-sml-mode-hook
hooks in that order, but after the
compiler is started. Use inferior-sml-mode-hook
to set any
comint
buffer-local configurations for SML mode you like.
Switch from the SML buffer to the interaction buffer. By default point will be placed at the end of the process buffer, but a prefix argument will leave point wherever it was before. If you try C-c C-s before an ML process has been started, you'll just get an error message to the effect that there's no current process buffer.
sml-cd-command
specifies the compiler command to invoke
(see section 5.4 Process defaults).
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Several commands are defined for sending program fragments to the running compiler. Each of the following commands takes a prefix argument that will switch the input focus to the process buffer afterwards (leaving point at the end of the buffer):
Send a `use file' command to the current ML process. The variable
sml-use-command
is used to define the correct template for the
command to invoke (see section 5.4 Process defaults). The default file is the
file associated with the current buffer, or the last file loaded if you
are in the interaction buffer.
Send the current region of text in the SML buffer.
sml-send-region-and-go
is a similar command for you to bind in
SML mode if you wish: it'll send the region and then switch-to-sml.
Send the contents of the current buffer to ML.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
SML mode provides one customisable function for locating the source
position of errors reported by the compiler. This should work whether
you type use "puzzle.sml";
into the interaction buffer, or use
one of the mechanisms provided for sending programs directly to the
compiler---see section 5.2 Speaking to the compiler.
Jump to the source location of the next error reported by the compiler. All the usual error-navigation commands are available, see see section `Compilation Mode' in The Emacs Editor Manual.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The process interaction code is independent of the compiler used, deliberately, so SML mode will work with a variety of ML compilers and ML-based tools. There are therefore a number of variables that may need to be set correctly before SML mode can speak to the compiler. Things are by default set up for Standard ML of New Jersey, but switching to a new system is quite easy.
"use \"%s\""
Use file command template. Emacs will replace the %s
with a file
name. Note that Emacs requires double quote characters inside strings
to be quoted with a backslash.
"OS.FileSys.chDir \"%s\""
Compiler command to change the working directory. Not all ML systems support this feature (well, Edinburgh (core) ML didn't), but they should.
"^[-=>#] *"
Matches the ML compiler's prompt: `comint' uses this for various purposes.
To customise error reportage for different ML compilers you need to set
two further variables before next-error
can be useful:
Alist that specifies how to match errors in compiler output. Each elt has the form (REGEXP FILE-IDX LINE-IDX [COLUMN-IDX FILE-FORMAT...]) If REGEXP matches, the FILE-IDX'th subexpression gives the file name, and the LINE-IDX'th subexpression gives the line number. If COLUMN-IDX is given, the COLUMN-IDX'th subexpression gives the column number on that line. If any FILE-FORMAT is given, each is a format string to produce a file name to try; %s in the string is replaced by the text matching the FILE-IDX'th subexpression.
[ << ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated by XEmacs shared group account on December, 19 2009
using texi2html 1.65.