Next Previous Up Top Contents Index

1 Using MLWorks interactively

1.8 Editing ML files

When MLWorks identifies an error in an ML file, one of the options it makes available is to load the file into your chosen editor at the line containing the error. To specify the editor you want to use, select Usage > General Preferences > Editor ... from the menu bar. The resulting dialog gives you several ways of specifying an editor:

To use the server, you will need to load some Emacs Lisp code into your Emacs session. You can do this by copying the code in the env/emacs file, under the directory where MLWorks is installed, into the file .emacs in your home directory. The MLWorks distribution also includes an sml-mode for Emacs. See the README file in the lib/emacs/lisp/ directory for information.
You can now make Emacs communicate with MLWorks by typing M-x mlworks-server in Emacs.
Note: If you are running MLWorks across a network, remember to ensure your Emacs session is running on the same host.
Use the External Editor text box to specify a command that would invoke a suitable editor if you typed it at the operating system command line (that is, in a UNIX shell). When you ask MLWorks to edit a file, it starts a new window in which the given command line, with the name of the file to be edited appended, is executed. If the command line includes %l, MLWorks will substitute an appropriate line number.

Note: Your choice of editor, like other settings and preferences selected from the Usage menu, can be saved by selecting Usage > Save Preferences. MLWorks writes the details of your preferences to a file called .mlworks_preferences in your home directory. The preferences file will be read in on starting subsequent MLWorks images.

Suppose that, having set your editor to something acceptable, you invoke File > Read Into Listener to run a file which contains an error. MLWorks reports the error in the listener, and brings up the error browser.

MLWorks> use "error.sml";
val it : unit = ()
Use: error.sml
error.sml:3,9 to 3,11: error: Unbound value boo

All errors in the first erroneous declaration in the file will be found, and they may be browsed in the usual way. The actions available are the same as when any error is encountered, with one exception: the Edit button on the error browser will start up your chosen editor, passing it the line number containing the error currently selected in the error browser.

Alternatively, you can position the cursor on the line in the listener where the location of the error is given, and select Edit > Edit Error. Again, MLWorks will start up your chosen editor at the line containing the error. This method allows you to edit a file containing an error even when you have switched off error browsers.

Editor settings and preferences can be controlled programmatically by the Shell.Editor and Shell.Options.Preferences structures. For full details, see the MLWorks Reference Manual.

1.8.1 - Custom editors

MLWorks User Guide version 2.0 for UNIX/Linux - 31 Jul 1998

Next Previous Up Top Contents Index

Generated with Harlequin WebMaker