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