Initial Commit
[packages] / xemacs-packages / haskell-mode / installation-guide.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2  "http://www.w3.org/TR/html4/strict.dtd">
3 <html><head>
4
5 <title>Haskell Mode for Emacs: Installation Guide</title>
6
7 </head><body>
8
9 <h1>Haskell Mode for Emacs: Installation Guide</h1>
10
11 <p>When Emacs is started up, it normally runs a file
12   called <code>~/.emacs</code> located in your home directory.  This file
13   should contain all of your personal customisations written as a series of
14   Elisp commands.  In order to install the Haskell mode, you have to tell
15   Emacs where to find it.  This is done by adding some commands to the init
16   file.</p>
17
18 <h2>Installation</h2>
19
20 <ul>
21   <li>If you are using XEmacs, the haskell-mode package should be
22       available for installation through the XEmacs package UI.
23
24   <li>If you are using Debian, you can install the package haskell-mode with
25     a command like "apt-get install haskell-mode".
26 </ul>
27
28 <p>Otherwise:</p>
29
30 <ul>
31   <li>Download and unpack the basic mode and modules into a suitable
32     directory, e.g. <code>~/lib/emacs</code> where <code>~</code> stands for
33     your home directory.
34
35   <li><p>Assuming you have placed the basic
36       mode <code>haskell-mode.el</code> and the modules you want to use in
37       the directory <code>~/lib/emacs</code>, add the following command to
38       your init file (<code>~/.emacs</code>):</p>
39
40     <pre>(load "~/lib/emacs/haskell-site-file")</pre>
41
42     <p>adding the following lines according to which modules you want to
43       use:</p>
44
45 <pre>
46 (add-hook 'haskell-mode-hook 'turn-on-haskell-doc-mode)
47 (add-hook 'haskell-mode-hook 'turn-on-haskell-indent)
48 (add-hook 'haskell-mode-hook 'turn-on-haskell-simple-indent)
49 </pre>
50
51     <p>Note that the two indentation modules are mutually exclusive - add at
52       most one.  <!-- You can download the above <a HREF=".emacs">code</a>. -->
53       Note that the line of code for simple indentation is commented out
54       (using a preceeding <code>;</code>) in preference for the more
55       advanced indentation module.  Installation is now complete!</p>
56
57     <p>The other modules are automatically loaded when needed in the
58       following way:
59       <ul>
60         <li>Font locking: just turn it on
61           via <code>global-font-lock-mode</code> or do
62           <pre>(add-hook 'haskell-mode-hook 'font-lock-mode)</pre>
63         <li>Declaration scanning: just use <code>M-x imenu</code> or
64           bind <code>imenu</code> to a key.  E.g.
65           <pre>(global-set-key [(control meta down-mouse-3)] 'imenu)</pre>
66           or you can also add it to the menubar with
67           <pre>(add-hook 'haskell-mode-hook 'imenu-add-menubar-index)</pre>
68         <li>Interaction with inferior Haskell interpreter:
69           just hit <code>C-c C-z</code> or <code>C-c C-l</code>.
70       </ul>
71
72 </ul>
73
74 <p>For those interested, each command above shall now be explained.</p>
75
76 <ol>
77   <li><p>We must ensure that the directory
78       containing <code>haskell-mode.el</code> is on
79       the <code>load-path</code> of Emacs.  You can examine the value of
80       the <code>load-path</code> by typing <code>C-h v load-path</code> in
81       an Emacs session.  Supposing that you've
82       placed <code>haskell-mode.el</code> in the
83       directory <code>~/lib/emacs</code>, if this directory is not on
84       the <code>load-path</code> we add it with:</p>
85
86     <pre>(setq load-path (cons "~/lib/emacs" load-path))</pre>
87
88     <p>The function <code>setq</code> sets the value of a variable, and the
89       function <code>cons</code> takes an element and a list and creates
90       a new list with the former as head and the latter as tail, as in
91       Haskell.</p>
92
93   <li><p>It is possible (and desirable) for Emacs to enter a specific mode
94       according to the name of the file being edited/visited.
95       The variable <code>auto-mode-alist</code> tells Emacs what mode to run
96       according to which regular expression matches the filename.  We wish
97       to run the Haskell mode on all files ending
98       in <code>.hs</code>, <code>.hi</code> (interface file)
99       and <code>.gs</code> (Gofer file), and to run the Haskell mode for
100       literate scripts on all files ending in <code>.lhs</code>
101       and <code>.lgs</code>.  To do this, we need to add pairs of the
102       form <code>(<em>regexp</em> . <em>mode-function</em>)</code>.  We use
103       the function <code>append</code> to append a list of three such pairs
104       to the end of the value of <code>auto-mode-alist</code>.  A list in
105       Elisp is written within round parantheses with elements separated by
106       whitespace.  A list is treated as a function application unless it is
107       quoted with <code>'</code>, which is what we do.</p>
108
109   <li><p>In order for Emacs to know where to find the definition of our mode
110       functions, <code>haskell-mode</code>
111       and <code>literate-haskell-mode</code>, we must use the
112       function <code>autoload</code>.  Both mode functions can be found in
113       the file <code>haskell-mode.el</code> which was downloaded in the
114       first installation step (the <code>.el</code> extension is left off
115       and assumed by Emacs).  As we have already ensured that this file is
116       on the <code>load-path</code> we need only give the filename and not
117       the directory.  Its use is quite straightforward but for further
118       information, see its documentation by entering <code>C-h
119         f autoload</code> in an Emacs session.</p>
120
121   <li><p>Each function <code>turn-on-haskell-<em>module</em></code> turns on
122       the corresponding module.  Adding such a function as a hook to the
123       Haskell mode will turn on that module when the mode is used.
124       Note that each of these modules may slow down Emacs, especially for
125       large files.</p>
126
127 </ol>
128
129 <h2>Customisation</h2>
130
131 <p>Most customisations are on the functionality of a particular module.
132   See the documentation of that module for information on its
133   customisation.</p>
134
135 <h2>Support</h2>
136
137 <p>Any problems, do <a HREF="mailto:monnier@iro.umontreal.ca">mail</a> and we
138   will try our best to help you!</p>
139
140 <p><a HREF="./"><em>Haskell Mode Home Page</em></a>.</p>