Import Upstream version 20180207
[hcoop/debian/mlton.git] / doc / guide / src / Emacs.adoc
1 Emacs
2 =====
3
4 == SML modes ==
5
6 There are a few Emacs modes for SML.
7
8 * `sml-mode`
9 ** http://www.xemacs.org/Documentation/packages/html/sml-mode_3.html
10 ** http://www.smlnj.org/doc/Emacs/sml-mode.html
11 ** http://www.iro.umontreal.ca/%7Emonnier/elisp/
12
13 * <!ViewGitFile(mlton,master,ide/emacs/mlton.el)> contains the Emacs lisp that <:StephenWeeks:> uses to interact with MLton (in addition to using `sml-mode`).
14
15 * http://primate.net/%7Eitz/mindent.tar, developed by Ian Zimmerman, who writes:
16 +
17 _____
18 Unlike the widespread `sml-mode.el` it doesn't try to indent code
19 based on ML syntax. I gradually got skeptical about this approach
20 after writing the initial indentation support for caml mode and
21 watching it bloat insanely as the language added new features. Also,
22 any such attempts that I know of impose a particular coding style, or
23 at best a choice among a limited set of styles, which I now oppose.
24 Instead my mode is based on a generic package which provides manual
25 bindable commands for common indentation operations (example: indent
26 the current line under the n-th occurrence of a particular character
27 in the previous non-blank line).
28 _____
29
30 == MLB modes ==
31
32 There is a mode for editing <:MLBasis: ML Basis> files.
33
34 * <!ViewGitFile(mlton,master,ide/emacs/esml-mlb-mode.el)> (plus other files)
35
36 == Definitions and uses ==
37
38 There is a mode that supports the precise def-use information that
39 MLton can output. It highlights definitions and uses and provides
40 commands for navigation (e.g., `jump-to-def`, `jump-to-next`,
41 `list-all-refs`). It can be handy, for example, for navigating in the
42 MLton compiler source code. See <:EmacsDefUseMode:> for further
43 information.
44
45 == Building on the background ==
46
47 Tired of manually starting/stopping/restarting builds after editing
48 files? Now you don't have to. See <:EmacsBgBuildMode:> for further
49 information.
50
51 == Error messages ==
52
53 MLton's error messages are not among those that the Emacs `next-error`
54 parser natively understands. The easiest way to fix this is to add
55 the following to your `.emacs` to teach Emacs to recognize MLton's
56 error messages.
57
58 [source,cl]
59 ----
60 (require 'compile)
61 (add-to-list 'compilation-error-regexp-alist 'mlton)
62 (add-to-list 'compilation-error-regexp-alist-alist
63 '(mlton
64 "^[[:space:]]*\\(\\(?:\\(Error\\)\\|\\(Warning\\)\\|\\(\\(?:\\(?:defn\\|spec\\) at\\)\\|\\(?:escape \\(?:from\\|to\\)\\)\\|\\(?:scoped at\\)\\)\\): \\(.+\\) \\([0-9]+\\)\\.\\([0-9]+\\)\\(?:-\\([0-9]+\\)\\.\\([0-9]+\\)\\)?\\.?\\)$"
65 5 (6 . 8) (7 . 9) (3 . 4) 1))
66 ----