Next: , Previous: , Up: Top   [Index]


7 Declaration scannning

haskell-decl-scan-mode is a minor mode which performs declaration scanning and provides M-x imenu support (see (emacs)Imenu for more information).

For non-literate and TeX-style literate scripts, the common convention that top-level declarations start at the first column is assumed. For Bird-style literate scripts, the common convention that top-level declarations start at the third column, ie. after ‘> ’, is assumed.

When haskell-decl-scan-mode is active, the standard Emacs top-level definition movement commands (see (emacs)Moving by Defuns) are enabled to operate on Haskell declarations:

C-M-a

Move to beginning of current or preceding declaration (beginning-of-defun).

C-M-e

Move to end of current or following declaration (end-of-defun).

C-M-h

Select whole current or following declaration (mark-defun).

Moreover, if enabled via the option haskell-decl-scan-add-to-menubar, a menu item “Declarations” is added to the menu bar listing the scanned declarations and allowing to jump to declarations in the source buffer.

It’s recommended to have font lock mode enabled (see (emacs)Font Lock) as haskell-decl-scan-mode ignores text highlighted with font-lock-comment-face.

As usual, in order to activate haskell-decl-scan-mode automatically for Haskell buffers, add turn-on-haskell-decl-scan to haskell-mode-hook:

(add-hook 'haskell-mode-hook 'turn-on-haskell-decl-scan)

haskell-decl-scan-mode enables the use of features that build upon imenu support such as Speedbar Frames (see (emacs)Speedbar) or the global “Which Function” minor mode (see (emacs)Which Function).

In order to enable which-function-mode for Haskell buffers you need to add the following to your Emacs initialization:

(eval-after-load "which-func"
  '(add-to-list 'which-func-modes 'haskell-mode))