1 \input texinfo @c -*-texinfo-*-
3 @comment "@(#)$Name$:$Id$"
5 @comment Documentation for the GNU Emacs SML mode.
6 @comment Copyright (C) 1999 (Anon)
8 @comment This file is part of the pcl-cvs distribution.
10 @comment sml-mode is free software; you can redistribute it and/or modify
11 @comment it under the terms of the GNU General Public License as published by
12 @comment the Free Software Foundation; either version 2 of the License,
13 @comment or (at your option) any later version.
15 @comment sml-mode is distributed in the hope that it will be useful,
16 @comment but WITHOUT ANY WARRANTY; without even the implied warranty of
17 @comment MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 @comment GNU General Public License for more details.
20 @comment You should have received a copy of the GNU General Public License
21 @comment along with sml-mode; see the file COPYING. If not, write to
22 @comment the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
24 @setfilename sml-mode.info
25 @settitle SML mode - The Emacs SML editing mode
28 * sml:(sml-mode). Emacs mode for editing SML
34 @center @titlefont{Editing and running Standard ML}
35 @center @titlefont{under GNU Emacs}
37 @center {SML mode, Version 3.3}
40 @author Author: Matthew J.@: Morley
43 @vskip 0pt plus 1filll
44 Copyright @copyright{} (Anon)
48 GNU General Public License as published by the Free Software Foundation;
49 either version 2, or (at your option) any later version.
53 SML mode is distributed in the hope that it will be useful, but
54 WITHOUT ANY WARRANTY; without even the implied warranty of
55 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
56 Public License for more details.
60 You should have received a copy of the GNU General Public License along
61 with GNU Emacs; see the file COPYING. If not, write to the Free Software
62 Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
66 @setchapternewpage off
69 @c ============================================================ TOP NODE
71 @node Top, Copying, (dir), (dir)
74 @chapter SML Mode Info
76 @c == Top, Copying, (dir), (dir) =======================================
79 You are looking at the top node of the Info tree documenting
80 @sc{sml-mode} (Version 3.3). Not all functions are documented here, but
81 those that aren't you probably won't miss. All commands and settable
82 variables have built-in documentation, as per usual Emacs conventions.
86 * Copying:: You can copy SML mode
87 * Introduction:: Setting things up
88 * SML Mode:: Editing SML source
89 * Interaction Mode:: Running ML processes
90 * Configuration:: Menus, highlighting, setting defaults
91 * Credits:: Credit and blame
94 * Command Index:: Commands you can invoke
95 * Variable Index:: Variables you can set
96 * Key Index:: Default keybindings
99 * Distribution:: What this distribution contains
100 * Getting Started:: What to tell Emacs
101 * Getting Help:: How Emacs can help
104 * Basics:: On entering SML mode
105 * Indentation:: Prettying SML text
106 * Magic Insertion:: Templates and electric keys
107 * SML Mode Defaults:: Variables controlling indentation
110 * Running ML:: Commands to run the ML compiler in a buffer
111 * ML Interaction:: Sending program fragments to the compiler
112 * Tracking Errors:: Finding reported syntax errors
113 * Process Defaults:: Setting defaults for process interaction
116 * Hooks:: Creating hooks
117 * Key Bindings:: Binding commands to keys
118 * Menus:: Taking advantage of bitmapped screens
119 * Highlighting:: Syntax colouring
120 * Advanced Topics:: You may need to speak Emacs Lisp
124 @c ============================================================= COPYING
126 @node Copying, Introduction, Top, Top
131 @c == Copying, Introduction, Top, Top ==================================
134 You can freely copy, modify and redistribute SML mode because it's
135 made available under the liberal terms of the GNU General Public
138 GNU General Public License as published by the Free Software Foundation;
139 either version 2, or (at your option) any later version.
141 SML mode is distributed in the hope that it will be useful, but
142 WITHOUT ANY WARRANTY; without even the implied warranty of
143 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
144 Public License for more details.
146 You should have received a copy of the GNU General Public License along
147 with GNU Emacs; see the file COPYING. If not, write to the Free Software
148 Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
155 @c ======================================================== INTRODUCTION
157 @node Introduction, SML Mode, Copying, Top
159 @chapter Introduction
161 @c == Introduction, SML Mode, Copying, Top =============================
165 SML mode is a major mode for Emacs for editing Standard ML. It has
166 some novel bugs, and some nice features:
170 Automatic indentation of sml code---a number of variables to customise
173 Easy insertion for commonly used templates like let, local, signature,
174 and structure declarations, with minibuffer prompting for types and
177 Magic pipe insertion: @code{|} automatically determines if it is used
178 in a case or fun construct, and indents the next line as appropriate,
179 inserting @code{=>} or the name of the function.
181 Inferior shell for running ML. There's no need to leave Emacs, just keep
182 on editing while the compiler runs in another window.
184 Automatic ``use file'' in the inferior shell---you can send files,
185 buffers, or regions of code to the ML subprocess.
187 Menus, and syntax and keyword highlighting supported for Emacs 19 and
190 Parsing errors from the inferior shell, and repositioning the
191 source---much like the next-error function used in c-mode.
193 SML mode can be easily configured to work with a number of Standard
194 ML compilers, and other SML based tools.
198 * Distribution:: What this distribution contains
199 * Getting Started:: What to tell Emacs
200 * Getting Help:: How Emacs can help
205 @c ======================================================== DISTRIBUTION
207 @node Distribution, Getting Started, Introduction, Introduction
209 @section The SML mode distribution
211 @c == Distribution, Getting Started, Introduction, Introduction ========
215 The distribution contains several Emacs Lisp files---this is for ease of
216 maintenance, you can concatenate them if you're careful:
220 Main file, and should work in any Emacs editor or version post
221 18.58---it only knows, or thinks it knows, about SML syntax and
225 Menus to access user settable features of the mode, and for those who
226 prefer menus over keys under Emacs 19 and derivatives.
228 @item sml-@{hilite,font@}.el
229 Syntax highlighting functions to display keywords in a bold font,
230 comments in italics, etc., using one of Emacs' two popular syntax
234 Process interaction requires the @file{comint} package (normally
235 distributed with Emacs 19 and derivatives).
237 @item sml-@{poly-ml,mosml@}.el
238 Auxiliary library support for Poly/ML and Moscow ML compilers.
239 @c Set these up to autoload from your @file{.emacs}.
243 @noindent There is also the Texinfo generated @code{info} file:
247 @item sml-mode.@{dvi,info@}
248 @c itemx sml-mode.dvi
249 This file---rudimentary SML mode documentation, and
252 Configuration file for system-wide installation. Read and edit this file
253 if you are installing SML mode for general use.
258 @c ===================================================== GETTING STARTED
260 @node Getting Started, Getting Help, Distribution, Introduction
262 @section Getting started
264 @c == Getting Started, Getting Help, Distribution, Introduction ========
268 With luck your system administrator will have installed SML mode
269 somewhere convenient, so all you have to do is put the line
276 in your @file{.emacs} configuration file and all will be well---you can
277 skip the rest of this getting started section. Otherwise you will need
278 to tell Emacs where to find all the SML mode @file{.el} files, and
279 when to use them. The where is addressed by locating the Lisp code on
280 your Emacs Lisp load path---you may have to create a directory for this,
281 say @file{/home/mjm/elisp}, and then insert the following lines in your
282 @file{/home/mjm/.emacs} file@footnote{cf.@: commentary in the site
283 initialisation file @file{sml-site.el}.}:
286 (setq load-path (cons "/home/mjm/elisp" load-path))
287 (autoload 'sml-mode "sml-mode" "Major mode for editing SML." t)
291 The first line adjusts Emacs' internal search path so it can locate the
292 Lisp source you have copied to that directory; the second line tells
293 Emacs to load the code automatically when it is needed. You can then
294 switch any Emacs buffer into SML mode by entering the command
301 It is usually more convenient to have Emacs automatically place the
302 buffer in SML mode whenever you visit a file containing ML
303 programs. The simplest way of achieving this is to put something like
306 (setq auto-mode-alist
307 (append '(("\\.sml$" . sml-mode)
308 ("\\.sig$" . sml-mode)
309 ("\\.ML$" . sml-mode)) auto-mode-alist))
313 also in your @file{.emacs} file. Subsequently (after a restart), any
314 files with these extensions will be placed in SML mode buffers when
318 You may want to pre-compile the @file{sml-*.el} files (@kbd{M-x
319 byte-compile-file}) for greater speed---byte compiled code loads and
320 runs somewhat faster.
322 @c If you are irritated by the fact that there are several @sc{sml}
323 @c mode lisp files concatenate them in the order I listed them (but
324 @c don't include @file{sml-site} which should be kept apart).
328 @c ======================================================== GETTING HELP
330 @node Getting Help, , Getting Started, Introduction
334 @c == Getting Help, , Getting Started, Introduction ====================
338 You're reading it. Apart from the on-line info tree (@kbd{C-h i} is the
339 Emacs key to enter the @code{info} system---you should follow the brief
340 tutorial if this is unfamiliar), there are further details on specific
341 commands in their documentation strings. Only the most useful
342 SML mode commands are documented in the info tree: to find out more
343 use Emacs' help facilities.
345 Briefly, to get help on a specific function use @kbd{C-h f} and enter
346 the command name. All (almost all, then) SML mode commands begin
347 with @code{sml-}, so if you type this and press @key{TAB} (for
348 completion) you will get a list of all commands. Another way is to use
349 @kbd{C-h a} and enter the string @code{sml}. This is command apropos; it
350 will list all commands with that sub-string in their names, and any key
351 binding they may have in the current buffer. Command apropos gives a
352 one-line synopsis of what each command does.
354 Some commands are also variables---such things are allowed in Lisp, if
355 not in ML! @xref{Command Index}, for a list of (info) documented
356 functions. @xref{Variable Index}, for a list of user settable variables
357 to control the behaviour of SML mode.
359 Before accessing this information on-line from within Emacs you may have
360 to set the variable @code{sml-mode-info}. Put in your @file{.emacs} file
363 @vindex sml-mode-info
364 @findex sml-mode-info
365 @kindex @kbd{C-c C-i}
367 (setq sml-mode-info "/home/mjm/info/sml-mode.info")
371 When different from the default this variable should be a string giving
372 the absolute name of the @file{.info} file. Then @kbd{C-c C-i} in
373 SML mode (i.e., the command @kbd{M-x sml-mode-info}) will bring up
374 the manual. This help is also accessible from the menu. (Resetting this
375 variable will not be necessary if your site administrator has been kind
376 enough to install SML mode and its attendant documentation in the
380 @c ============================================================ SML MODE
382 @node SML Mode, Interaction Mode, Introduction, Top
384 @chapter Editing with SML Mode
386 @c == SML Mode, Interaction Mode, Introduction, Top ====================
390 Now SML mode provides just a few additional editing commands. Most
391 of the work (@pxref{Credits,,Credit & Blame}) has gone into implementing
392 the indentation algorithm which, if you think about it, has to be
393 complicated for a language like ML. @xref{SML Mode Defaults,,Indentation
394 Defaults}, for details on how to control some of the behaviour of the
395 indentation algorithm. Principal goodies are the `electric pipe'
396 feature, and the ability to insert common SML forms (macros or
400 * Basics:: On entering SML mode
401 * Indentation:: Prettying SML text
402 * Magic Insertion:: Templates and electric keys
403 * SML Mode Defaults:: Variables controlling indentation
407 @c ============================================================== BASICS
409 @node Basics, Indentation, SML Mode, SML Mode
411 @section On entering SML mode
413 @c == Basics, Indentation, SML Mode, SML Mode ==========================
418 @deffn Command sml-mode
419 This switches a buffer into SML mode. This is a @emph{major mode} in
420 Emacs. To get out of SML mode the buffer's major mode must be set to
421 something else, like @t{text-mode}. @xref{Getting Started}, for details
422 on how to set this up automatically when visiting an SML file.
425 Emacs is all hooks of course. A hook is a variable: if the variable is
426 non-nil it binds a list of Emacs Lisp functions to be run in some order
427 (usually left to right). You can customise SML mode with these
431 @defvr Hook sml-mode-hook
434 This is run every time a new SML mode buffer is created (or if you
435 type @kbd{M-x sml-mode}). This is one place to put your preferred key
436 bindings. @xref{Configuration}, for some examples.
440 @defvr Hook sml-load-hook
441 Default: @code{'sml-mode-version}
443 Another, maybe better, place for key bindings. This hook is only run when
444 SML mode is loaded into Emacs. @xref{Configuration}.
448 @deffn Command sml-mode-version
449 Prints the current version of SML mode in the mini-buffer, in case
450 you need to know. I've put it on @code{sml-load-hook} so you can easily
451 tell which version of SML mode you are running.
456 @c ========================================================= INDENTATION
458 @node Indentation, Magic Insertion, Basics, SML Mode
460 @section Automatic indentation
462 @c == Indentation, Magic Insertion, Basics, SML Mode ===================
466 ML is a complicated language to parse, let alone compile. The
467 indentation algorithm is a little wooden (for some tastes), and the best
468 advice is not to fight it! There are several variables that can be
469 adjusted to control the indentation algorithm (@pxref{SML Mode
470 Defaults,,Customising SML Mode}, below).
473 @deffn Command sml-indent-line
477 This command indents the current line. If you set the indentation of the
478 previous line by hand, @code{sml-indent-line} will indent relative to
483 @deffn Command sml-indent-region
487 Indent the current region. Be patient if the region is large (like the
492 @deffn Command sml-back-to-outer-indent
493 Key: @kbd{M-@key{TAB}}
494 @kindex @kbd{M-@key{TAB}}
496 Unindents the line to the next outer level of indentation.
501 Further indentation commands that Emacs provides (generically, for all
502 modes) that you may like to recall:
506 @kbd{M-x newline-and-indent}
508 On @key{LFD} by default.
510 Insert a newline, then indent according to the major mode. @xref{Program
511 Indent,,Indentation for Programs,emacs,The Emacs Editor Manual}, for
515 @kbd{M-x indent-rigidly}
517 On @kbd{C-x @key{TAB}} by default.
518 @kindex @kbd{C-x @key{TAB}}
519 Moves all lines in the region right by its argument (left, for negative
520 arguments). @xref{Indentation,,,emacs,The Emacs Editor Manual}.
523 @kbd{M-x indent-for-comment}
525 On @kbd{M-;} by default.
527 Indent this line's comment to comment column, or insert an empty
528 comment. @xref{Comment Commands,,,emacs,The Emacs Editor
532 @kbd{M-x indent-new-comment-line}
534 On @kbd{M-@key{LFD}} by default.
535 @kindex @kbd{M-@key{LFD}}
536 Break line at point and indent, continuing comment if within one.
537 @xref{Multi-Line Comments,,,emacs,The Emacs Editor Manual}.
541 As with other language modes, @kbd{M-;} gives you a comment at the end
542 of the current line. The column where the comment starts is determined
543 by the variable @code{comment-column}---default is 40, but it can be
544 changed with @code{set-comment-column} (on @kbd{C-x ;} by default).
547 @c ===================================================== MAGIC INSERTION
549 @node Magic Insertion, SML Mode Defaults, Indentation, SML Mode
551 @section Electric features
553 @c == Magic Insertion, SML Mode Defaults, Indentation, SML Mode ========
557 Electric keys are generally pretty irritating, so those provided by
558 SML mode are fairly muted. The only truly electric key is @kbd{;},
559 and this has to be enabled to take effect.
562 @deffn Command sml-electric-pipe
566 When the point is in a `case' statement this opens a new line, indents
567 and inserts @code{| =>} leaving point just before the double arrow; if
568 the enclosing construct is a `fun' declaration, the newline is indented
569 and the function name copied at the appropriate column. Generally, try
570 it whenever a @code{|} is wanted---you'll like it!
574 @deffn Command sml-electric-semi
578 Just inserts a semi-colon, usually. The behaviour of this command is
579 governed by the variable @code{sml-electric-semi-mode}.
583 @defvr {Command, Variable} sml-electric-semi-mode
586 If this variable is @code{nil}, @code{sml-electric-semi} just inserts a
587 semi-colon, otherwise it inserts a semi-colon and a newline, and indents
588 the newline for SML. The command toggles the value of the variable; if
589 you give the command a prefix argument (i.e., @kbd{C-u M-x
590 sml-electric-semi-mode}) this always disables the electric effect of
595 @deffn Command sml-insert-form
596 Key: @kbd{C-c @key{RET}}
597 @kindex @kbd{C-c @key{RET}}
599 Interactive short-cut to insert common ML forms (a.k.a.@: macros, or
600 templates). Recognised forms are `let', `local', `case', `abstype',
601 `datatype', `signature', `structure', and `functor'. Except for `let'
602 and `local', these will prompt for appropriate parameters like functor
603 name and signature, etc.. This command prompts in the mini-buffer, with
606 By default @kbd{C-c @key{RET}} will insert at point, with the
607 indentation of the current column; if you give a prefix argument (i.e.,
608 @kbd{C-u C-c @key{RET}}) the command will insert a newline first,
609 indent, and then insert the template.
612 @code{sml-insert-form} is also extensible: see @ref{Configuration} for
617 @c ======================================================= MODE DEFAULTS
619 @node SML Mode Defaults, , Magic Insertion, SML Mode
621 @section Indentation defaults
623 @c == SML Mode Defaults, , Magic Insertion, SML Mode ===================
627 Several variables try to control the indentation algorithm and other
628 features of SML mode. For these user settable variables there is
629 generally a function of the same name that does the job---look for them
630 in the menu under @emph{Format/Mode Variables}.
633 @defvr {Command, Variable} sml-indent-level
634 @findex sml-indent-level
637 This variable controls the block indentation level. The command prompts
638 for a numeric value unless a numeric prefix is provided instead. For
639 example @kbd{M-2 M-x sml-indent-level} will set the variable to 2
644 @defvr {Command, Variable} sml-pipe-indent
645 @findex sml-pipe-indent
648 This variable adjusts the indentation level for lines that begin with a
649 @code{|} (after any white space). The extra offset is usually negative.
650 The command prompts for a numeric value unless a numeric prefix is
655 @defvar sml-paren-lookback
658 The number of characters the indentation algorithm searches for an
659 opening parenthesis. 1000 characters is about 30-40 lines; larger values
660 mean slower indentation. If the value of the variable is @code{nil} this
661 means the indentation algorithm won't look back at all.
665 If the default values are not acceptable you can set these variables
666 permanently in your @file{.emacs} file. @xref{Configuration}, for
667 details and examples. Three further variables control the behaviour of
671 @defvr {Command, Variable} sml-case-indent
672 @findex sml-case-indent
675 How to indent `case' expressions:
679 @r{If @code{t}:} @r{If @code{nil}:}
680 case expr case expr of
681 of exp1 => ... exp1 => ...
682 | exp2 => ... | exp2 => ...
687 If @code{t}: If @code{nil}:
688 case expr case expr of
689 of exp1 => ... exp1 => ...
690 | exp2 => ... | exp2 => ...
694 The first seems to be the standard in SML/NJ. The second is the (nicer?)
699 @defvr {Command, Variable} sml-nested-if-indent
700 @findex sml-nested-if-indent
703 Nested `if-then-else' expressions have the following indentation
704 depending on the value.
708 @r{If @code{t}:} @r{If @code{nil}:}
709 if exp1 then exp2 if exp1 then exp2
710 else if exp3 then exp4 else if exp3 then exp4
711 else if exp5 then exp6 else if exp5 then exp6
717 If @code{t}: If @code{nil}:
718 if exp1 then exp2 if exp1 then exp2
719 else if exp3 then exp4 else if exp3 then exp4
720 else if exp5 then exp6 else if exp5 then exp6
727 @defvr {Command, Variable} sml-type-of-indent
728 @findex sml-type-of-indent
731 Determines how to indent `let', `struct', etc..
735 @r{If @code{t}:} @r{If @code{nil}:}
736 fun foo bar = let fun foo bar = let
745 If @code{t}: If @code{nil}:
746 fun foo bar = let fun foo bar = let
754 @code{sml-type-of-indent} will not have any effect if the starting
755 keyword is the first word on the line.
761 @c ========================================================= INTERACTION
763 @node Interaction Mode, Configuration, SML Mode, Top
765 @chapter Running ML under Emacs
767 @c == Interaction Mode, Configuration, SML Mode, Top ===================
771 The most useful feature of SML mode is that it provides a convenient
772 interface to the compiler. How serious users of ML put up with a
773 teletype interface to the compiler is beyond me@.@.@. but perhaps there
774 are other interfaces to compilers that require one to part with serious
775 money. Such remarks can quickly become dated---in this case, let's hope
778 Anyway, SML mode provides an interaction mode,
779 @code{inferior-sml-mode}, where the compiler runs in a separate buffer
780 in a window or frame of its own. You can use this buffer just like a
781 terminal, but it's usually more convenient to mark some text in the
782 SML mode buffer and have Emacs communicate with the sub-process. The
783 features discussed below are syntax-independent, so they should work
784 with a wide range of ML-like tools and compilers. @xref{Process
785 Defaults}, for some hints.
787 @findex inferior-sml-mode
788 @code{inferior-sml-mode} is a specialisation of the @file{comint}
789 package that comes with GNU Emacs and GNU XEmacs.
793 * Running ML:: Commands to run the ML compiler in a buffer
794 * ML Interaction:: Sending program fragments to the compiler
795 * Tracking Errors:: Finding reported syntax errors
796 * Process Defaults:: Setting defaults for process interaction
801 @c ========================================================== RUNNING ML
803 @node Running ML, ML Interaction, Interaction Mode, Interaction Mode
805 @section Starting the compiler
807 @c == Running ML, ML Interaction, Interaction Mode, Interaction Mode ==
810 Start your favourite ML compiler with the command
817 This creates a process interaction buffer that inherits some key
818 bindings from SML mode and from @file{comint} (@pxref{Shell Mode, ,
819 , emacs, The Emacs Editor Manual}). Starting the ML compiler adds some
820 functions to SML mode buffers so that program text can be
821 communicated between editor and compiler (@pxref{ML Interaction}).
823 The name of the ML compiler is the first thing you should know how to
827 @defvar sml-program-name
828 Default: @code{"sml"}
830 The program to run as ML. You might need to specify the full path name
835 @defvar sml-default-arg
838 Useful for Poly/ML users who may supply a database file, or others who
839 have wrappers for setting various options around the command to run the
840 compiler. Moscow ML people might set this to @code{"-P full"}, etc..
843 The variable @code{sml-program-name} is a string holding the name
844 of the program @emph{as you would type it at the shell}. You
845 can always choose a program different to the default by invoking
848 @kbd{C-u M-x run-sml}
852 With the prefix argument Emacs will prompt for the command name and any
853 command line arguments to pass to the compiler. Thereafter Emacs will
854 use this new name as the default, but for a permanent change you should
855 set this in your @file{.emacs} with, e.g.:
858 (setq sml-program-name "nj-sml")
862 You probably shouldn't set this in @code{sml-mode-hook} because that
863 will interfere if you occasionally run a different compiler (e.g.,
864 @code{poly} or @code{hol90}).
868 @deffn Command run-sml
869 Launches ML as an inferior process in another buffer; if an ML process
870 already exists, just switch to the process buffer. A prefix argument
871 allows you to edit the command line to specify the program, and any
872 command line options.
876 @defvr Hook inferior-sml-mode-hook
879 @kbd{M-x run-sml} runs @code{comint-mode-hook} and
880 @code{inferior-sml-mode-hook} hooks in that order, but @emph{after} the
881 compiler is started. Use @code{inferior-sml-mode-hook} to set any
882 @code{comint} buffer-local configurations for SML mode you like.
886 @defvr Hook inferior-sml-load-hook
889 This hook is analogous to @code{sml-load-hook} and is run just after the
890 code for @code{inferior-sml-mode} is loaded into Emacs. Use this to set
891 process defaults, and preferred key bindings for the interaction buffer.
895 @deffn Command switch-to-sml
897 @kindex @kbd{C-c C-s}
899 Switch from the SML buffer to the interaction buffer. By default point
900 will be placed at the end of the process buffer, but a prefix argument
901 will leave point wherever it was before. If you try @kbd{C-c C-s} before
902 an ML process has been started, you'll just get an error message to the
903 effect that there's no current process buffer.
907 @deffn Command sml-cd
908 When started, the ML compiler's default working directory is the
909 current buffer's default directory. This command allows the working
910 directory to be changed, if the compiler can do this. The variable
911 @code{sml-cd-command} specifies the compiler command to invoke
912 (@pxref{Process Defaults}).
917 @c @findex inferior-sml-mode
918 @c It's unlikely you will ever need this, but @code{inferior-sml-mode} is
919 @c the command that will put the current buffer into ML interaction mode.
920 @c Note that if you try @kbd{C-c C-s} before an ML process has been
921 @c started, you'll just get an error message to the effect that there's no
922 @c current process buffer.
926 @c ======================================================== SENDING TEXT
928 @node ML Interaction, Tracking Errors, Running ML, Interaction Mode
930 @section Speaking to the compiler
932 @c == ML Interaction, Tracking Errors, Running ML, Interaction Mode ====
936 Several commands are defined for sending program fragments to the
937 running compiler. Each of the following commands takes a prefix argument
938 that will switch the input focus to the process buffer afterwards
939 (leaving point at the end of the buffer):
942 @deffn Command sml-load-file
944 @kindex @kbd{C-c C-l}
946 Send a `use file' command to the current ML process. The variable
947 @code{sml-use-command} is used to define the correct template for the
948 command to invoke (@pxref{Process Defaults}). The default file is the
949 file associated with the current buffer, or the last file loaded if you
950 are in the interaction buffer.
955 @deffn Command sml-send-region
956 @findex sml-send-region-and-go
958 @kindex @kbd{C-c C-r}
960 Send the current region of text in the SML buffer.
961 @code{sml-send-region-and-go} is a similar command for you to bind in
962 SML mode if you wish: it'll send the region and then switch-to-sml.
965 @deffn Command sml-drag-region
966 Key: @kbd{M-S-down-mouse-1}
967 @kindex @kbd{M-S-down-mouse-1}
969 It's sometimes irritating to do all that @kbd{C-@@} and @kbd{C-c C-r}
970 stuff to send regions to the ML process, so if you are running Emacs
971 under X Windows (say) you can do the same job by holding down both the
972 @key{SHIFT} and @key{META} keys, and dragging with mouse button one over
973 the region. This will temporarily highlight the region as you move the
974 mouse, like @code{mouse-drag-region} (i.e., @kbd{down-mouse-1}),
975 and send the highlighted text straight into the jaws of the ML compiler.
977 If you only click the mouse button, instead of dragging, the region of
978 text sent to the compiler is delimited by the current position of point
979 and the place where you click the mouse. In neither case will the
980 command set the region.
983 @c @deffn Command sml-send-function
984 @c @findex sml-send-function-and-go
986 @c Send the enclosing `function' definition. Contrary to the suggestive
987 @c name, this command @emph{does not} try to determine the extent of the
988 @c function definition because that is too difficult with ML. Instead
989 @c this just sends the enclosing @emph{paragraph} (delimited by blank
990 @c lines or form-feed characters).
993 @deffn Command sml-send-buffer
995 @kindex @kbd{C-c C-b}
997 Send the contents of the current buffer to ML.
1000 @c Two further commands are defined for you to bind to keys if you wish:
1001 @c @code{sml-send-region-and-go} and @code{sml-send-function-and-go}. Both
1002 @c automatically switch to the interaction buffer.
1005 By and large, Emacs can nowadays quite happily send large chunks of text
1006 to its subprocesses (@file{comint} does input splitting). However, it is
1007 still probably safest@footnote{XEmacs 19.11 users are warned that
1008 changing the default @code{sml-temp-threshold} may well cause XEmacs to
1009 hang; they seem to have fixed the problem in 19.12 and above.} to send
1010 larger program fragments to ML via the temporary file mechanism. This,
1011 for @code{sml-send-region} and other SML mode commands that use it
1012 in some way, takes advantage of the ML compiler's ability to open a file
1013 and compile the contents by making a temporary file of the indicated
1014 text. Two variables of interest are:
1017 @defvar sml-temp-threshold
1020 Determines what constitutes a large program fragment. A value of 512,
1021 say, will declare half a kilobyte a suitable threshold and larger
1022 fragments will be sent via a temporary file. A value of 0 means
1023 @emph{all} text is sent via a temporary file; the value @code{nil}
1024 inhibits the temporary file mechanism altogether.
1028 @defvar sml-temp-file
1029 Default: @code{(make-temp-name "/tmp/ml")}
1031 A string that gives the name of the temporary file to use. This
1032 default ensures Emacs will invent a unique name for this purpose for
1033 use throughout the rest of the editing session. Only one temporary
1038 Another reason, you might well say @emph{the reason}, for using the
1039 temporary file mechanism is that error messages reported by the ML
1040 compiler (@pxref{Tracking Errors}) are generally useless to SML mode
1041 unless a real file is associated with the input (an embedded @emph{use
1042 file} will count as a real file). Of course, this all rather depends on
1043 the compiler producing sensible error messages, and on SML mode
1044 being able to parse them.
1047 @c ===================================================== TRACKING ERRORS
1049 @node Tracking Errors, Process Defaults, ML Interaction, Interaction Mode
1051 @section Finding errors
1053 @c == Tracking Errors, Process Defaults, ML Interaction, Interaction Mode
1057 SML mode provides one customisable function for locating the source
1058 position of errors reported by the compiler. This should work whether
1059 you type @code{use "puzzle.sml";} into the interaction buffer, or use
1060 one of the mechanisms provided for sending programs directly to the
1061 compiler---@pxref{ML Interaction}.
1064 @deffn Command sml-next-error
1065 @findex sml-skip-errors
1069 Jump to the source location of the next error reported by the compiler.
1070 If the function bound to @code{sml-error-parser} returns a range of
1071 character positions for the location of the error in the source file,
1072 @code{sml-next-error} will put the mark at the end of the range with
1073 point at the beginning; it may also highlight the region specified; it
1074 will also echo the one-line text of the error message if the error
1075 parser returns one.@footnote{Does @code{sml-error-parser} return these
1076 nice things? The answer is complicated! @xref{Advanced Topics}, and the
1077 docstring @kbd{C-h v sml-error-parser}.}
1079 If you enter @kbd{C-u C-c`} instead, the command (a.k.a.@:
1080 @code{sml-skip-errors}) skips past all the remaining error messages and
1081 removes any error overlay in the current buffer. Note that @kbd{C-c`}
1082 also works in the ML interaction buffer (by default).
1086 @defvr {Variable, Command} sml-error-overlay
1087 @findex sml-error-overlay
1090 Legal default values for this buffer-local variable are @code{t} and
1091 @code{nil}. The variable attains a local value in each SML mode
1092 buffer when the default is @code{t}; in this case the local value is an
1093 overlay (or @emph{extent} in XEmacs speak), and this means
1094 @code{sml-next-error} will highlight errors in the buffer when it can.
1095 If the default is @code{nil} it stays that way and @code{sml-next-error}
1096 will not highlight anything, ever.
1098 The command @kbd{M-x sml-error-overlay} will set the overlay around the
1099 current region, or remove the overlay if a prefix argument is given
1100 (i.e., @kbd{C-u M-x sml-error-overlay} removes the overlay, but this
1101 functionality can be accessed from the menu to save typing).
1105 Note that SML mode will usually locate errors relative to the start
1106 of the last major program fragment sent to the compiler (via
1107 @code{sml-load-file}, etc.), but if you don't use the temporary file
1108 mechanism to communicate text to the ML process (@pxref{Process
1109 Defaults}), errors will generally not be located at all.
1112 @c ==================================================== PROCESS DEFAULTS
1114 @node Process Defaults, , Tracking Errors, Interaction Mode
1116 @section Process defaults
1118 @c == Process Defaults, , Tracking Errors, Interaction Mode ============
1121 The process interaction code is independent of the compiler used,
1122 deliberately, so SML mode will work with a variety of ML compilers
1123 and ML-based tools. There are therefore a number of variables that may
1124 need to be set correctly before SML mode can speak to the compiler.
1125 Things are by default set up for Standard ML of New Jersey, but
1126 switching to a new system is quite easy---very easy if you are using
1127 Poly/ML or Moscow ML as these are supported by libraries bundled with
1132 @defvar sml-use-command
1133 Default: @code{"use \"%s\""}
1135 Use file command template. Emacs will replace the @code{%s} with a file
1136 name. Note that Emacs requires double quote characters inside strings
1137 to be quoted with a backslash.
1141 @defvar sml-cd-command
1142 Default: @code{"OS.FileSys.chDir \"%s\""}
1144 Compiler command to change the working directory. Not all ML systems
1145 support this feature (well, Edinburgh (core) ML didn't), but they
1150 @defvar sml-prompt-regexp
1151 Default: @code{"^[\-=] *"}
1153 Matches the ML compiler's prompt: @file{comint} uses this for various
1158 To customise error reportage for different ML compilers you need to set
1159 two further variables before @code{sml-next-error} can be useful:
1162 @defvar sml-error-regexp
1163 Default: @code{sml-smlnj-error-regexp}
1165 This is the regular expression for matching the start of an error
1166 message. The default matches the Standard ML of New Jersey compiler's
1167 Error and Warning messages. If you don't want stop at Warnings try, for
1170 "^[-= ]*.+:[0-9]+\\.[0-9]+.+Error:"
1172 If you're using Edinburgh (core) ML try @code{"^Parse error:"}.
1176 @defvar sml-error-parser
1177 Default: @code{'sml-smlnj-error-parser}
1179 The function that actually parses the error message. Again, the default
1180 is for SML/NJ. If you need to change this you may have to do a little
1181 Emacs Lisp programming.
1185 Note that bundled libraries supply an @code{sml-mosml-error-parser} and
1186 an @code{sml-poly-ml-error-parser}, and set all the attendant compiler
1187 variables. @xref{Advanced Topics}, for tips on how to program your own
1188 compiler extension to SML mode.
1191 @c A typical way of (re)setting these variables correctly is to put
1192 @c something in your @file{.emacs} file that resembles
1195 @c (setq sml-use-command "PolyML.use \"%s\"")
1196 @c (setq sml-prompt-regexp "^[>#] *")
1200 @c probably on @code{inferior-sml-load-hook} (but @pxref{Configuration},
1204 @c ======================================================= CONFIGURATION
1206 @node Configuration, Credits, Interaction Mode, Top
1208 @chapter Configuration Summary
1210 @c == Configuration, Credits, Interaction Mode, Top ===================
1212 @c @footnote{@url{http://www.ahl.co.uk/}}
1213 @c @footnote{@url{http://www.dina.kvl.dk/~sestoft/mosml.html}}
1216 This (sort of pedagogic) section gives more information on how to
1217 configure SML mode: menus, key bindings, hooks and highlighting are
1218 discussed, along with a few other random topics. First, though, the
1219 auxiliary files @file{sml-poly-ml.el} and @file{sml-mosml.el} define
1220 defaults for these popular (?) ML compilers---Poly/ML and Moscow ML,
1221 respectively. One way to setup SML mode to use Moscow ML is to add
1222 to your @file{.emacs}:
1225 (defun my-mosml-setup () "Initialise inferior SML mode for Moscow ML."
1226 (load-library "sml-mosml.el")
1227 (setq sml-program-name "/home/mjm/mosml/bin/mosml"))
1228 (add-hook 'inferior-sml-load-hook 'my-mosml-setup)
1232 which creates a hook function @code{my-mosml-setup} and adds it to
1233 @code{inferior-sml-load-hook} so that the defaults for
1234 @code{sml-error-regexp} and its ilk (@pxref{Process Defaults}) are
1235 correctly initialised; I have to set @code{sml-program-name} explicitly
1236 here because that directory isn't on my (Unix) PATH. The story is
1237 similar if you use Poly/ML.
1238 Note, by the way, that order matters here: the @code{load-library} call
1239 comes first because the default for @code{sml-program-name} in
1240 @file{sml-mosml.el} is just @code{"mosml"}.
1243 @c (eval-after-load "sml-proc" '(my-mosml-setup))
1246 @c is perhaps a better way to achieve the same effect, but last time I
1247 @c looked this wouldn't work in XEmacs.
1249 The auxiliary libraries bundled with SML mode define commands
1250 @code{sml-mosml} and @code{sml-poly-ml} (there's also an
1251 @code{sml-smlnj} for uniformity); these commands prompt for suitable
1252 values for @code{sml-program-name} and @code{sml-default-arg} before
1253 starting the compiler and setting the other process defaults. A prefix
1254 argument will give you the builtin defaults with no questions asked.
1257 * Hooks:: Creating them
1258 * Key Bindings:: Binding commands to keys
1259 * Menus:: Taking advantage of bitmapped screens
1260 * Highlighting:: Syntax colouring
1261 * Advanced Topics:: You may need to speak Emacs Lisp
1265 @c =============================================================== HOOKS
1267 @node Hooks, Key Bindings, Configuration, Configuration
1271 @c == Hooks, Key Bindings, Configuration, Configuration ================
1275 One way to set SML mode variables (@pxref{SML Mode
1276 Defaults,,Indentation Defaults}), and other defaults, is through the
1277 @code{sml-mode-hook} in your @file{.emacs}. A simple example:
1280 (defun my-sml-mode-hook () "Local defaults for SML mode"
1281 (setq sml-indent-level 2) ; conserve on horizontal space
1282 (setq words-include-escape t) ; \ loses word break status
1283 (setq indent-tabs-mode nil)) ; never ever indent with tabs
1284 (add-hook 'sml-mode-hook 'my-sml-mode-hook)
1287 The body of @code{my-sml-mode-hook} is a sequence of bindings. In this
1288 case it is not really necessary to set @code{sml-indent-level} in a hook
1289 because this variable is global (most SML mode variables are). With
1293 (setq sml-indent-level 2)
1296 anywhere in your @file{.emacs} file (but probably on
1297 @code{sml-load-hook}). The variable @code{indent-tabs-mode} is
1298 automatically made local to the current buffer whenever it is set
1299 explicitly, so it @emph{must} be set in a hook if you always want
1300 SML mode to behave like this. The same goes for the buffer-local
1301 @code{sml-error-overlay}; since this is globally @code{t} by default,
1302 set it globally @code{nil} if you never want errors highlighted:
1305 (setq-default sml-error-overlay nil)
1308 Again, on @code{sml-load-hook} would probably be the best place.
1311 Another hook is @code{inferior-sml-mode-hook}. This can be used to
1312 control the behaviour of the interaction buffer through various
1313 variables meaningful to @file{comint}-based packages:
1316 (defun my-inf-sml-mode-hook () "Local defaults for inferior SML mode"
1317 (add-hook 'comint-output-filter-functions 'comint-truncate-buffer)
1318 (setq comint-scroll-show-maximum-output t)
1319 (setq comint-input-autoexpand nil))
1320 (add-hook 'inferior-sml-mode-hook 'my-inf-sml-mode-hook)
1323 Again, the body is a sequence of bindings. Unless you run several ML
1324 compilers simultaneously under one Emacs, this hook will normally only
1325 get run once. You might want to look up the documentation (@kbd{C-h v}
1326 and @kbd{C-h f}) for these buffer-local @code{comint} things.
1329 @c ======================================================== Key Bindings
1331 @node Key Bindings, Menus, Hooks, Configuration
1333 @section Key bindings
1335 @c == Key Bindings, Menus, Hooks, Configuration ========================
1339 Customisation (in Emacs) usually entails putting favourite commands on
1340 easily remembered keys. Two `keymaps' are defined in SML mode: one
1341 is effective in program text buffers (@code{sml-mode-map}) and the other
1342 is effective in interaction buffers (@code{inferior-sml-mode-map}).
1343 The initial design ensures that (many of) the default key bindings from
1344 the former keymap will also be available in the latter (e.g.,
1347 Type @kbd{C-h m} in an SML mode buffer to find the default key
1348 bindings (and similarly in an ML interaction buffer), and use the hooks
1349 provided to install your preferred key bindings. Given that the keymaps
1350 are global (variables):
1353 (defun my-sml-load-hook () "Global defaults for SML mode"
1354 (define-key sml-mode-map "\C-cd" 'sml-cd)
1355 (define-key sml-mode-map "\C-co" 'sml-error-overlay))
1356 (add-hook 'sml-load-hook 'my-sml-load-hook)
1359 This has the effect of binding @code{sml-cd} to the key @kbd{C-c d}, and
1360 the command @code{sml-error-overlay} to the key @kbd{C-c o}. If you want
1361 the same behaviour from @kbd{C-c d} in the ML buffer:
1364 (defun my-inf-sml-load-hook () "Global defaults for inferior SML mode"
1365 (define-key inferior-sml-mode-map "\C-cd" 'sml-cd)
1366 ;; NB. for SML/NJ '96
1367 (setq sml-cd-command "OS.FileSys.chDir \"%s\""))
1368 (add-hook 'inferior-sml-load-hook 'my-inf-sml-load-hook)
1371 There is nothing to stop you rebuilding the entire keymap for
1372 SML mode and the ML interaction buffer in your @file{.emacs} of
1373 course: SML mode won't define @code{sml-mode-map} or
1374 @code{inferior-sml-mode-map} if you have already done so.
1377 @c =============================================================== Menus
1379 @node Menus, Highlighting, Key Bindings, Configuration
1383 @c == Menus, Highlighting, Key Bindings, Configuration =================
1387 Menus are useful for fiddling with mode defaults and finding out what
1388 keys commands are on if you are forgetful (not all commands are listed
1389 in the menu). For menus to appear in the menu bar under GNU Emacs or GNU
1390 XEmacs, the editor must be able to find one of two packages---i.e., one
1391 or both must be on your @code{load-path}. The first option is
1392 @file{easymenu} which is distributed with GNU Emacs. Easy!
1394 The second option is @file{auc-menu} which was written by Per Abrahamsen
1395 and distributed with AUCTeX, but it is independently available from the
1396 IESD lisp archive@footnote{@url{ftp://sunsite.auc.dk/packages/auctex/}}
1397 at Aalborg. You'll also find @file{auc-menu} is available from the LCD
1398 archive@footnote{@url{ftp://archive.cis.ohio-state.edu/pub/gnu/emacs/elisp-archive/misc/}},
1399 the main repository for all Emacs Lisp. The advantage of @file{auc-menu}
1400 is that it works with XEmacs too.
1402 Notice that certain menu entries are not illuminated at first---these
1403 are generally functions that depend on there being an ML process running
1404 with which to communicate.
1407 @c ======================================================== Highlighting
1409 @node Highlighting, Advanced Topics, Menus, Configuration
1411 @section Syntax colouring
1413 @c == Highlighting, Advanced Topics, Menus, Configuration ==============
1417 Highlighting is very handy for picking out keywords in the program text,
1418 spotting misspelled kewyords, and, if you have Emacs' @file{ps-print}
1419 package installed (you usually do these days), obtaining pretty, even
1420 colourful code listings---quite properly for your colourful ML programs.
1422 @vindex sml-font-lock-extra-keywords
1423 @vindex sml-font-lock-auto-on
1425 Various highlight (hilite, if you spell real bad!) packages are
1426 available for GNU Emacs 19, and GNU XEmacs. SML mode can use either
1427 @file{hilit19} which only comes with Emacs, or @file{font-lock} which is
1428 the package of choice with XEmacs. If you are not familiar with these
1429 highlight packages you'll have to check their sources for installation
1432 Use @code{sml-load-hook} to tell Emacs which scheme you prefer for
1433 SML mode. For example:
1436 (add-hook 'sml-load-hook '(lambda () (require 'sml-font)))
1440 This ensures the SML extensions to @file{font-lock} will be available
1441 once SML mode loads (from @file{sml-font.el}---if you prefer
1442 @file{hilit19} you should @code{(require 'sml-hilite)} instead.
1444 The variable @code{sml-font-lock-extra-keywords} is for further
1445 customising @file{font-lock} for SML mode. The value of the variable
1446 should be a list of strings, each of which is a regular expression that
1447 should match the desired keyword exactly. Here's an example:
1450 (setq sml-font-lock-extra-keywords
1451 '("\\babstraction\\b" "\\bfunsig\\b" "=>" "::"))))
1455 The @code{\b} marks a word boundary, according to the syntax table
1456 defined for SML mode. Backslash must be quoted inside a string.
1457 @xref{Regexps,,,emacs,The Emacs Editor Manual}, for a summary of Emacs'
1458 regular expression syntax.
1461 Finally, the variable @code{sml-font-lock-auto-on} can be used to
1462 control whether or not @file{font-lock} should be enabled by default in
1463 SML mode buffers; it is enabled by default. The @code{sml-hilite}
1464 package is customisable, but only with regard to colour changes.
1467 @c ===================================================== ADVANCED TOPICS
1469 @node Advanced Topics, , Highlighting, Configuration
1471 @section Advanced Topics
1473 @c == Advanced Topics, , Highlighting, Configuration ===================
1476 * Forms:: These forms are bloody useless; can't we have better ones?
1477 * Indents:: I hate that indentation algorithm; can't I suppress it?
1478 * Multi ML:: Can SML mode handle more than one compiler running at once?
1479 * Other ML:: What needs to be done to support other ML compilers?
1483 @node Forms, Indents, Advanced Topics, Advanced Topics
1486 @emph{These forms are bloody useless; can't we have better ones?}
1491 You can indeed. @code{sml-insert-form} is extensible so all you need to
1492 do is create the macros yourself. Define a @emph{keybord macro}
1493 (@kbd{C-x (} <something> @kbd{C-x )}) and give it a suitable name:
1494 @code{sml-addto-forms-alist} prompts for a name, say @code{NAME}, and
1495 binds the macro @code{sml-form-NAME}. Thereafter @kbd{C-c @key{RET}
1496 NAME} will insert the macro at point, and @kbd{C-u C-c @key{RET} NAME}
1497 will insert the macro after a @code{newline-and-indent}. If you want to
1498 keep your macros from one editing session to the next, go to your
1499 @file{.emacs} file and call @code{insert-kbd-macro}; you'll need
1500 to add @code{NAME} to @code{sml-forms-alist} permanently yourself:
1503 (defun my-sml-load-hook () "Global defaults for SML mode"
1504 ;; whatever else you do
1505 (setq sml-forms-alist (cons '("NAME") sml-forms-alist)))
1508 If you want to create templates like `case' that prompt for parameters
1509 you'll have to do some Lisp programming. The @code{tempo} package looks
1510 like a good stating point. You can always overwrite your own macros, but
1511 the builtin forms for `let', etc., can't be overwritten.
1514 @node Indents, Multi ML, Forms, Advanced Topics
1518 @emph{I hate that indentation algorithm; can't I suppress it?}
1523 Ah, yes, a common complaint. It's actually very easy to use SML mode
1524 without the troublesome @code{sml-indent-line}:
1527 (defun my-sml-load-hook () "Global defaults for SML mode"
1528 ;; whatever else you do
1529 (fset 'sml-indent-line 'ignore))
1532 though @code{indent-relative-maybe} may conceivable be more useful than
1536 @node Multi ML, Other ML, Indents, Advanced Topics
1540 @emph{Can SML mode handle more than one compiler running at once?}
1547 The question is whether you can! See the @code{sml-buffer} variable's
1548 on-line help (@kbd{C-h v sml-buffer}). Note that the SML mode
1549 compiler variables (@pxref{Process Defaults}) are all buffer-local, so
1550 you can even switch between different ML compilers, not just different
1551 invocations of the same one. Well, you @emph{can}.
1555 @node Other ML, , Multi ML, Advanced Topics
1559 @emph{What needs to be done to support other ML compilers?}
1564 Not that much really, at least not to create minimal support. The
1565 interface between SML mode and the compiler is determined by the
1567 @code{sml-use-command},
1568 @code{sml-cd-command},
1569 @code{sml-prompt-regexp}
1570 (which are easy to get right), and
1571 @code{sml-error-regexp}, and
1572 @code{sml-error-parser} (which are more tricky).
1573 The general template to follow in setting this up
1574 is in the files @file{sml-@{poly-ml,mosml@}.el}.
1575 These rules will not change, I hope:
1579 @code{sml-next-error} uses @code{sml-error-regexp} to locate the start
1580 of the next error report in the ML interaction buffer (@var{P})
1583 @code{sml-next-error} calls @code{sml-error-parser}, passing @var{P}, and
1584 expects up to five return values in this order:
1587 @item file name in which the error occurs (@var{F})
1588 @item start line of the error (@var{L} > 0)
1589 @item start column of the error (@var{C})
1590 @item an Emacs Lisp expression to be @code{eval}'d
1591 at (@var{L},@var{C}) in @var{F} (@var{EOE})
1592 @item the actual text of the one-line error report (@var{MSG})
1597 @code{sml-error-parser} can assume that @var{P} is the start of the next
1598 error message that the user is interested in---since she defines this
1599 point by defining @code{sml-error-regexp}.
1602 What @code{sml-error-parser} returns is a list. In the event of problems,
1603 I foresee the following needs:
1606 @item if the file is the standard input,
1607 return @code{("std_in" @var{L} @var{C})}
1608 @item if the file cannot be inferred,
1609 return @code{(nil @var{L} @var{C})}
1610 @item if @var{L}=0, or the start cannot be inferred,
1611 return @code{(@var{F} nil @var{C})}
1612 @item if the start column cannot be inferred,
1613 return @code{(@var{F} @var{L} 1)}
1617 There's no need to return anything else. However, if you do want the
1618 errorful text in @var{F} highlighted you should return a simple Lisp
1619 expression in the fourth argument that'll compute the region. @var{EOE}
1620 will be called with point at character (@var{L},@var{C}) in @var{F}, and
1621 should move point to the end of the errorful text. In fact, @var{EOE}
1622 can actually do anything you wish, but in the simplest cases it'll just
1623 @code{(forward-char 45)}, or
1626 (progn (forward-line 4) (forward-char 37))
1629 etc.. If it does more, make sure it leaves point at the end of the
1630 region in @var{F}---use @code{save-excursion} if switching buffers.
1631 @var{MSG}, if returned, will be echoed in the minibuffer.
1633 @c ============================================================== CREDIT
1635 @c H A C K A T T A C K O N
1637 @c H A C K A T T A C K O F F
1639 @node Credits, Command Index, Configuration, Top
1641 @unnumbered Credit & Blame
1643 @c == Credits, Command Index, Configuration, Top =======================
1646 SML Mode was written originally by Lars Bo Nielsen for Emacs 18.5n;
1647 later hacked for comint by Olin Shivers (who called it @t{ml-mode});
1648 much later hacked by myself because it didn't seem to work@dots{} Fritz
1649 Knabe brilliantly posted the @code{hilit19} and @code{font-lock}
1650 functions on the net. Lars probably would recognise much of what
1651 remains, yet now there're menus, syntax highlighting, support for
1652 various ML compilers, Texinfo (hey!), and more than a little hope it'll
1653 work with a variety of Emacs 19s. But there are still things to do. Lars
1656 @emph{The indentation algorithm still can be fooled. I don't know if it will
1657 ever be 100% right, as this means it will have to actually parse all of
1658 the buffer up to the actual line [@dots{}].}
1661 This is still the main cause of grief; SML's syntax is a nightmare for
1662 Emacs modes, and of course opinions vary about proper indentation. But
1663 there may be something we can do@dots{}
1665 @c ======================================================= COMMAND INDEX
1667 @headings singleafter
1669 @node Command Index, Variable Index, Credits, Top
1671 @unnumbered Command Index
1673 @c == Command Index, Variable Index, Credits, Top ======================
1677 @c ====================================================== VARIABLE INDEX
1679 @c node Variable Index, , Command Index, Top
1680 @node Variable Index, Key Index, Command Index, Top
1682 @unnumbered Variable Index
1684 @c == Variable Index, Key Index, Command Index, Top ====================
1688 @c =========================================================== KEY INDEX
1690 @node Key Index, , Variable Index, Top
1692 @unnumbered Key Index
1694 @c == Key Index, , Variable Index, Top =================================