1. xemacs
  2. haskell-mode


haskell-mode / installation-guide.html


<title>Haskell Mode for Emacs: Installation Guide</title>


<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


  <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".


  <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

(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)

    <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:
	<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 the 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>.


<p>For those interested, each command above shall now be explained.</p>

  <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

  <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>



<p>Most customisations are on the functionality of a particular module.
  See the documentation of that module for information on its


<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>