haskellemacsautocompletehaskell-mode

Haskell autocompletion in Emacs using haskell-mode


I installed haskel-mode in emacs. Then I write in my .emacs:

(load "~/.emacs.d/haskell-mode/haskell-site-file")
(add-hook 'haskell-mode-hook 'turn-on-haskell-doc-mode)
(add-hook 'haskell-mode-hook 'turn-on-haskell-indentation)
(add-hook 'haskell-mode-hook 'haskell-font-lock-symbols t)
(put 'downcase-region 'disabled nil)

What must I add in my conf file that emacs could autocomplete for Haskell? Or Haskell mode there is no such possibility?


Solution

  • When there is no language-specific support, you can use tags. This is a generic completion mechanism.

    1. Generate a TAGS file, which contains a list of identifiers and where they are defined. Emacs comes with the etags program to do this in many languages, but not Haskell; ghc comes with hasktags.

    2. Load the TAGS file with M-x visit-tags-table.

    Tags are not context-dependent, so they'll indiscriminately suggest types, values, constructors, etc everywhere. They also won't provide advanced features such as easily showing the type of a value. The most important tags commands are:

    For more information, look under "Tags" in the Emacs manual.


    For an even cruder, but fully automatic mechanism, there is the dynamic abbrev feature. C-M-/ (dabbrev-completion) looks in most open buffers for a completion; this is completely language-independent, so it'll even find words in strings, comments, whatever. M-/ (dabbrev-expand) is similar, but directly completes to the nearest match before point.