An experimental feature is use of the w3m browser to browse Haddock docs inside Emacs.
Most Linux distributions will have a package for the binary:
$ sudo apt-get install w3m
Confirm installation by trying M-x
If this works, you’re good to go.
Now that you have w3m, you probably want to configure it to be more of a passive viewer than a full-fledged browser. For example:
(setq w3m-mode-map (make-sparse-keymap)) (define-key w3m-mode-map (kbd "RET") 'w3m-view-this-url) (define-key w3m-mode-map (kbd "q") 'bury-buffer) (define-key w3m-mode-map (kbd "<mouse-1>") 'w3m-maybe-url) (define-key w3m-mode-map [f5] 'w3m-reload-this-page) (define-key w3m-mode-map (kbd "C-c C-d") 'haskell-w3m-open-haddock) (define-key w3m-mode-map (kbd "M-<left>") 'w3m-view-previous-page) (define-key w3m-mode-map (kbd "M-<right>") 'w3m-view-next-page) (define-key w3m-mode-map (kbd "M-.") 'w3m-haddock-find-tag) (defun w3m-maybe-url () (interactive) (if (or (equal '(w3m-anchor) (get-text-property (point) 'face)) (equal '(w3m-arrived-anchor) (get-text-property (point) 'face))) (w3m-view-this-url)))
It’s not enabled by default in haskell-mode at present, so you need to import it manually:
In order to make haddock pages a little more palatable (and add syntax highlighting to source view), you can add this hook:
(add-hook 'w3m-display-hook 'w3m-haddock-display)
It’s a little rough around the edges, but it’s a start.
By default, the package locations is set to:
(defcustom haskell-w3m-haddock-dirs '("~/.cabal/share/doc/"))
If you are using an hsenv or a custom package directory, you should configure this variable with M-x customize-variable or by writing the custom-set-variables code for it.
You did all that! Now you’re ready to bind a useful key:
(define-key haskell-mode-map (kbd "C-c C-d") 'haskell-w3m-open-haddock)
Now when you press C-c C-d it will prompt for a package to browse to.
This feature will be improved gradually as time goes on.