Commits

Anonymous committed 7229720

Update haskell-mode to upstream version 2.1. See the xemacs-patches message
with message ID <m37j6w70gs.fsf@jerrypc.cs.usu.edu>.

Comments (0)

Files changed (20)

.emacs

-(setq load-path (cons "~/lib/emacs" load-path))
-(setq auto-mode-alist
-      (append auto-mode-alist
-              '(("\\.[hg]s$"  . haskell-mode)
-                ("\\.hi$"     . haskell-mode)
-                ("\\.l[hg]s$" . literate-haskell-mode))))
-(autoload 'haskell-mode "haskell-mode"
-   "Major mode for editing Haskell scripts." t)
-(autoload 'literate-haskell-mode "haskell-mode"
-   "Major mode for editing literate Haskell scripts." t)
-(add-hook 'haskell-mode-hook 'turn-on-haskell-font-lock)
-(add-hook 'haskell-mode-hook 'turn-on-haskell-decl-scan)
-(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)
-(add-hook 'haskell-mode-hook 'turn-on-haskell-hugs)
+2006-03-14  Jerry James  <james@xemacs.org>
+
+	* .emacs: Remove.
+	* ChangeLog.upstream: New file.
+	* Makefile: Update AUTHOR_VERSION.  Add rule for new
+	inf-haskell.el.  Put text files in EXTRA_SOURCES.
+	* Makefile.upstream: New file.
+	* NEWS: New file.
+	* package-info.in: Update provides.
+
+	* fontlock.hs:
+	* haskell-decl-scan.el:
+	* haskell-doc.el:
+	* haskell-font-lock.el:
+	* haskell-ghci.el:
+	* haskell-hugs.el:
+	* haskell-indent.el:
+	* haskell-mode.el:
+	* haskell-simple-indent.el:
+	* inf-haskell.el:
+	* indent.hs:  Sync with upstream version 2.1.
+
+	* index.html: Ditto, with small changes to make onsgmls like it.
+	* installation-guide.html: Ditto, also with small changes.
+
 2004-06-16  Norbert Koch  <viteno@xemacs.org>
 
 	* Makefile (VERSION): XEmacs package 1.07 released.

ChangeLog.upstream

+2005-11-07  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* Release version 2.1.
+
+	* haskell-indent.el (haskell-indent-inside-comment): Rename `start' arg
+	into `open' and add a new `start' arg.
+	(haskell-indent-after-keywords): Change defaults for `in'.
+	(haskell-indent-indentation-info): Fix confusion between pos and col.
+	(haskell-indent-mode): Autoload.
+
+	* haskell-indent.el (haskell-indent-find-matching-start):
+	Add `pred' and `start' arguments.
+	(haskell-indent-filter-let-no-in): New fun.
+	(haskell-indent-indentation-info): Use them to correctly match `let's
+	with `in's even when some of the `let's have no matching `in'.
+
+2005-11-06  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* haskell-indent.el: Reduce the use of dyn-bound haskell-indent-info.
+	(haskell-indent-push-col): Don't duplicate info.
+	(haskell-indent-line-indentation): Handle let-in-do.  Remove dead code.
+	(haskell-indent-inside-comment): Move rest of code from
+	haskell-indent-indentation-info.
+
+	* haskell-indent.el (haskell-literate): Declare.
+	(haskell-running-xemacs, event-basic-type, read-event): Remove.
+	(haskell-indent-get-beg-of-line, haskell-indent-get-end-of-line):
+	Remove.  Use line-(beginning|end)-position instead.
+	(haskell-indent-mark-active): Move the xemacs test inside the defun.
+	(haskell-indent-info): Rename from indent-info.  Update users.
+	(haskell-indent-bolp, haskell-indent-inside-comment):
+	Use line-beginning-position.
+	(haskell-indent-within-literate-code): Use `case'.
+	(haskell-indent-put-region-in-literate): Bind more comment-* vars.
+	(haskell-indent-virtual-indentation): Add the missing `start' arg.
+	(haskell-indent-mode): Move before first use.
+	(haskell-indent-stand-alone-mode): Use haskell-indent-mode.
+	Rename from haskell-stand-alone-indent-mode.  Use define-derived-mode.
+	(hugs-mode-map, hugs-syntax-table):
+	Rename to haskell-stand-alone-indent-mode-(map|syntax-table).
+
+	* haskell-doc.el (haskell-doc-xemacs-p, haskell-doc-emacs-p)
+	(haskell-doc-message): Remove.
+	(haskell-doc-is-id-char-at): Remove.
+	(haskell-doc-get-current-word): Rewrite.
+
+2005-11-04  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* haskell-indent.el (haskell-indent-indentation-info): Fix detection of
+	hanging let/if/case statements.
+
+	* haskell-mode.el (haskell-mode): Fix typo.
+
+2005-11-04  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* inf-haskell.el (inferior-haskell-mode): Hide compilation bindings.
+
+	* haskell-indent.el (haskell-indent-after-keywords): New var.
+	(haskell-indent-virtual-indentation): New fun.
+	(haskell-indent-indentation-info): Use them to indent after keywords.
+
+	* haskell-simple-indent.el (haskell-simple-indent): Minor simplif.
+	(turn-on-haskell-simple-indent): Don't bind \t and \n.
+
+	* haskell-mode.el (haskell-vars, haskell-mode-generic): Remove.
+	(haskell-mode-hook): Rename from haskell-mode-hooks.
+	(haskell-mode): Use define-derived-mode.  Inline haskell-mode-generic
+	and haskell-vars.
+	(literate-haskell-mode): Use define-derived-mode.
+
+	* fontlock.hs: Add some entries for infix declarations.
+
+2005-10-12  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* haskell-indent.el (haskell-indent-start-keywords-re): Use regexp-opt.
+	(haskell-indent-type-at-point): Accept ' in identifiers.
+	(haskell-indent-find-case): Tell match-data to not generate markers.
+	(haskell-indent-line-indentation): Ignore off-side keywords in comments
+	and strings.
+	(haskell-indent-find-matching-start): Generalize.
+	Rename from haskell-indent-find-let.
+	(haskell-indent-indentation-info): Use it for of, then, and else.
+
+2005-09-28  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* haskell-indent.el (haskell-indent-in-comment): Don't fail at EOB.
+
+	* haskell-font-lock.el (haskell-font-lock-symbols-alist): Add "not".
+	(haskell-font-lock-compose-symbol): Handle alphanum identifiers.
+	Fix incorrect handling of . when used for qualified names.
+
+2005-09-26  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* haskell-font-lock.el (haskell-font-lock-symbols-alist): Prefer the
+	unicode version of lambda.  Add two symbols from the Omega language and
+	from Paterson's arrow syntax.
+
+2005-08-24  Steve Chamberlain  <sac@pobox.com>  (tiny patch)
+
+	* haskell-doc.el (haskell-doc-message): Paren typo.
+
+2005-08-23  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* haskell-doc.el (haskell-doc-show-type): Assume that the availability
+	of display-message won't change at runtime.
+
+	* haskell-font-lock.el (haskell-font-lock-keywords-create): Try and
+	work around a bug that seems to be in Emacs-21.3 rather than in
+	haskell-font-lock.el.  Reported by Steve Chamberlain <sac@pobox.com>.
+
+2005-07-18  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* inf-haskell.el (haskell-program-name): Fix defcustom delcaration.
+
+	* haskell-doc.el (haskell-doc-message): Remove.
+	(haskell-doc-show-type): Inline it.  Don't do anything for if there's
+	no doc to show.
+
+2005-02-02  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* haskell-hugs.el (haskell-hugs-mode-map):
+	* haskell-ghci.el (haskell-ghci-mode-map): Remove.
+
+2005-01-26  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* haskell-indent.el (haskell-indent-inside-comment): Don't assume that
+	column(pos+2) = column(pos)+2.
+	(haskell-indent-indentation-info): Fix indentation of , and ;.
+	Add arg `start'.  Restrict choice of indentation for comments.
+	(haskell-indent-event-type): Remove.
+	(haskell-indent-last-info): New var.
+	(haskell-indent-cycle): Use it to store info from one invocation to
+	the next, so we can do cycling outside of the function.
+	Don't cycle directly any more.  Instead, recognize repeated invocations
+	via last-command and friends.
+	Use indent-line-function rather than hardcoding indent-to-left-margin.
+	(haskell-indent-insert-where): Don't save excursion.
+	(haskell-indent-layout-indent-info): Minor simplifications.
+	(haskell-indent-line-indentation): Don't ignore code on a line
+	before a string.
+
+	* haskell-hugs.el (haskell-hugs-last-loaded-file): Remove.
+	(haskell-hugs-start-process): Fix misuse of make-variable-buffer-local.
+	(haskell-hugs-go): Quote file name.  Simplify.
+
+	* haskell-ghci.el (haskell-ghci-last-loaded-file): Remove.
+	(haskell-ghci-start-process): Fix misuse of make-variable-buffer-local.
+	(haskell-ghci-go): Quote file name.  Simplify.
+
+	* haskell-mode.el (haskell-version): Keep it up-to-date.
+
+	* inf-haskell.el (inferior-haskell-load-file): Quote file name.
+
+2004-12-10  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* haskell-indent.el (haskell-indent-start-of-def): Only go backward.
+	(haskell-indent-in-string): Simplify.
+	(haskell-indent-in-comment): Simplify.
+	(haskell-indent-comment): Remove.
+	(haskell-indent-inside-comment): New fun.
+	(haskell-indent-indentation-info): Assume we're at the indentation.
+	Handle comments differently.
+	(haskell-indent-cycle): Go to indentation and then save excursion
+	around haskell-indent-indentation-info.
+
+	* haskell-doc.el (haskell-doc-minor-mode-string): Make it dynamic.
+	(haskell-doc-install-keymap): Remove conflicting C-c C-o binding.
+	(haskell-doc-mode): Make a nil arg turn the mode ON.
+	(turn-on-haskell-doc-mode): Make it an alias for haskell-doc-mode.
+	(haskell-doc-mode): Don't touch haskell-doc-minor-mode-string.
+	(haskell-doc-show-global-types): Don't touch
+	haskell-doc-minor-mode-string.  Call haskell-doc-make-global-fct-index.
+	(haskell-doc-check-active): Fix message.
+	(define-key-after): Don't define.
+	(haskell-doc-install-keymap): Check existence of define-key-after.
+
+	* haskell-mode.el (haskell-literate-default): Fix custom type.
+	(haskell-vars): Ignore comments when doing C-M-f.
+
+	* indent.hs: More test cases.
+
+	* inf-haskell.el (haskell-program-name): Use ghci if hugs is absent.
+	(inferior-haskell-load-file): Reset compilation-parsing-end.
+
+2004-11-25  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* Release version 2.0.
+
+	* .emacs: Remove.
+
+	* haskell-decl-scan.el (haskell-ds-imenu-label-cmp): Undo last
+	idiotic change.
+
+	* haskell-doc.el (haskell-doc-sym-doc): Make even the last char bold.
+
+	* haskell-mode.el (haskell-mode-map): Typo.
+
+	* inf-haskell.el (inferior-haskell-mode): Typo.
+	(inferior-haskell-wait-for-output): Remove.
+	(inferior-haskell-send-command): New function.
+	(inferior-haskell-load-file): Use it.
+
+	* index.html:
+	* installation-guide.html: Partial fixup.
+
+2004-11-24  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* haskell-mode.el (turn-on-haskell-hugs, turn-on-haskell-ghci):
+	Mark them as obsolete.
+	(haskell-mode-map): Add bindings for the inferior-haskell commands.
+
+	* inf-haskell.el: New file.
+
+	* haskell-doc.el (haskell-doc-install-keymap): Don't blindly assume
+	there's a Hugs menu.
+
+2004-11-22  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* haskell-indent.el (turn-on-haskell-indent, turn-off-haskell-indent):
+	Use C-c C-foo rather than C-c foo to follow coding conventions.
+
+	* haskell-font-lock.el (haskell-font-lock-symbols-alist): Add . = ○.
+
+2004-10-25  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* haskell-indent.el (haskell-indent-indentation-info): Don't use layout
+	for paren-closing elements.
+
+2004-10-20  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* haskell-indent.el (haskell-indent-indentation-info): Only use
+	the new `in' indentation rule if the `let' is on the left of the decl.
+
+2004-10-19  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* haskell-indent.el (haskell-indent-find-let): New function.
+	(haskell-indent-indentation-info): Use it to indent `in'.
+
+	* haskell-font-lock.el (haskell-default-face): Add missing declaration.
+
+	* haskell-indent.el (haskell-indent-open-structure): Simplify.
+	(haskell-indent-contour-line): Work even when `start' is in the middle
+	of a line.
+	(haskell-indent-layout-indent-info): New fun extracted from
+	haskell-indent-indentation-info.
+	(haskell-indent-indentation-info): Use it as before.  Use it also to
+	handle layout-within-open-structure.
+
+2004-10-18  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* haskell-font-lock.el (haskell-font-lock-keywords-create):
+	Use explicit `symbol-value' to work around limitations in XEmacs's
+	implementation of font-lock.
+	(haskell-basic-syntactic-keywords): Fix up char-constants some more.
+
+2004-10-14  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* haskell-doc.el (turn-off-haskell-doc-mode)
+	(haskell-doc-current-info): Don't autoload.
+
+	* haskell-decl-scan.el (haskell-ds-match-string):
+	Use match-string-no-properties if available.
+	(haskell-ds-syntax-table): Use haskell-mode-syntax-table.
+	(haskell-ds-imenu-label-cmp): Use car-less-than-car if available.
+	(haskell-ds-imenu): Remove obsolete incorrect code.
+
+	* haskell-mode.el: Set things up so that mode-hook functions are not
+	necessary, and generic functions can be used instead, like
+	global-font-lock-mode.
+	(haskell-enum-from-to): Remove.
+	(turn-on-haskell-font-lock): Make obsolete.
+	(haskell-running-xemacs): Remove.
+	(haskell-mode-syntax-table): Fiddle with non-ascii chars.
+	Fix up comment syntax in XEmacs.
+	(haskell-vars): Improve comment-start-skip.
+	Add comment-end-skip.  Setup imenu, eldoc, and font-lock.
+	Tweak handling of tabs to be on the safe side.
+	(haskell-mode-hooks): Declare and mention some useful ideas.
+	(literate-haskell-mode): Simplify.
+	(haskell-comment-indent): Remove.  The default works as well.
+
+	* haskell-font-lock.el: Remove level 1 fontification.
+	(haskell-font-lock-keywords-1, haskell-font-lock-keywords-2)
+	(bird-literate-haskell-font-lock-keywords-1)
+	(bird-literate-haskell-font-lock-keywords-2)
+	(latex-literate-haskell-font-lock-keywords-1)
+	(latex-literate-haskell-font-lock-keywords-2): Remove.
+	(bird-literate-haskell-font-lock-keywords)
+	(latex-literate-haskell-font-lock-keywords): Rename.
+	(haskell-font-lock-keywords-create): Remove `level' arg.
+	(haskell-fl-syntax): Remove.  Assume the major modes sets it right.
+	(haskell-font-lock-choose-keywords)
+	(haskell-font-lock-choose-syntactic-keywords): New funs.
+	(haskell-font-lock-defaults-create): Use them.
+	(turn-off-haskell-font-lock, turn-on-haskell-font-lock): Simplify.
+
+	* haskell-hugs.el (haskell-hugs-mode): Use define-derived-mode.
+	(run-hugs): New alias.
+	(haskell-hugs-wait-for-output): Don't loop if the process is dead.
+
+	* haskell-font-lock.el (haskell-font-lock-compose-symbol): New fun.
+	(haskell-font-lock-symbols-keywords): Use it.
+	(haskell-string-char-face): Remove.
+	(haskell-font-lock-keywords-create): Hardcode font-lock-string-face.
+	(haskell-fl-syntax): Fix typos.  Keep " as a string delimiter.
+
+2004-10-13  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* haskell-doc.el (haskell-doc): New group.
+	(haskell-doc-show-reserved, haskell-doc-show-prelude)
+	(haskell-doc-show-strategy, haskell-doc-show-user-defined)
+	(haskell-doc-chop-off-context, haskell-doc-chop-off-fctname):
+	Make them custom vars.
+	(haskell-doc-keymap): Declare and fill it right there.
+	(haskell-doc-mode): Simplify.
+	(haskell-doc-toggle-var): Make it into what it was supposed to be.
+	(haskell-doc-mode-print-current-symbol-info): Simplify.
+	(haskell-doc-current-info): New autoloaded function.
+	(haskell-doc-sym-doc): New fun extracted from haskell-doc-show-type.
+	(haskell-doc-show-type): Use it.
+	(haskell-doc-wrapped-type-p): Remove unused var `lim'.
+	(haskell-doc-forward-sexp-safe, haskell-doc-current-symbol):
+	Remove.  Unused.
+	(haskell-doc-visit-home): Don't require ange-ftp, it's autoloaded.
+	(haskell-doc-install-keymap): Simplify.
+
+	* haskell-decl-scan.el (literate-haskell-ds-create-imenu-index)
+	(haskell-ds-generic-create-imenu-index): Remove.
+	(haskell-ds-bird-p): New function.
+	(haskell-ds-backward-decl, haskell-ds-forward-decl): Use it.
+	(haskell-ds-create-imenu-index): Use it to make it generic.
+	(haskell-ds-imenu): Remove now-unused arg.
+	(turn-on-haskell-decl-scan): Fix up call to haskell-ds-imenu.
+	(haskell-ds-running-xemacs): Remove.
+	(haskell-ds-func-menu-next): Make generic.
+	(literate-haskell-ds-func-menu-next): Delete.
+	(haskell-ds-func-menu): Remove unused arg.
+	(turn-on-haskell-decl-scan): Simplify.
+
+	* haskell-indent.el: Don't load CL at runtime.
+	(haskell-indent-start-of-def, haskell-indent-type-at-point):
+	Don't hardcode point-min == 1.
+	(indent-info): Declare it.
+	(haskell-indent-empty, haskell-indent-ident, haskell-indent-other)
+	(haskell-indent-line-indentation): Use `string'.
+	(haskell-indent-valdef-indentation): Fix `case' arms syntax.
+	(haskell-indent-indentation-info): Remove unused var `pt'.
+	(haskell-indent-align-def): Remove unused var `defpos'.
+	(turn-on-haskell-indent): Don't bind TAB.
+	(turn-off-haskell-indent): Don't unbind TAB and DEL.
+	(hugs-syntax-table): Use the `n' for nested comments.
+	(haskell-stand-alone-indent-mode): Fix `comment-end'.
+
+;; Local Variables:
+;; coding: utf-8
+;; End:
+
+# arch-tag: a2606dc4-fab7-4b2f-bbe9-0a51db643511
 # Boston, MA 02111-1307, USA.
 
 VERSION = 1.07
-AUTHOR_VERSION = 1.45
+AUTHOR_VERSION = 2.1
 MAINTAINER = Jerry James <james@xemacs.org>
 PACKAGE = haskell-mode
 PKG_TYPE = regular
 
 ELCS = haskell-decl-scan.elc haskell-doc.elc haskell-font-lock.elc \
 	haskell-ghci.elc haskell-hugs.elc haskell-indent.elc haskell-mode.elc \
-	haskell-simple-indent.elc
+	haskell-simple-indent.elc inf-haskell.elc
 
 DATA_FILES = fontlock.hs indent.hs index.html installation-guide.html
 DATA_DEST = $(PACKAGE)
 
+EXTRA_SOURCES = ChangeLog.upstream Makefile.upstream NEWS
+
 PRELOADS = -l comint -l cus-face -l font-lock -l func-menu -l imenu \
 	-l haskell-mode -l haskell-indent
 

Makefile.upstream

+EMACS = emacs
+
+ELFILES = \
+	haskell-font-lock.el \
+	haskell-mode.el \
+	haskell-doc.el \
+	haskell-decl-scan.el \
+	inf-haskell.el \
+	haskell-indent.el
+
+ELCFILES = $(ELFILES:.el=.elc)
+# AUTOLOADS = $(PACKAGE)-startup.el
+AUTOLOADS = haskell-site-file.el
+
+%.elc: %.el
+	$(EMACS) --batch --eval '(setq load-path (cons "." load-path))' \
+		-f batch-byte-compile $<
+
+all: $(ELCFILES) $(AUTOLOADS)
+
+info:
+	# No Texinfo file, sorry.
+
+######################################################################
+###                    don't look below                            ###
+######################################################################
+
+PACKAGE=haskell-mode
+
+$(AUTOLOADS): $(ELFILES)
+	[ -f $@ ] || echo '
+	$(EMACS) --batch --eval '(setq generated-autoload-file "'`pwd`'/$@")' -f batch-update-autoloads "."
+
+##
+
+TAG = $(shell echo v$(VERSION) | tr '.' '_')
+ftpdir=/u/monnier/html/elisp/
+cvsmodule=$(shell cat CVS/Repository)
+cvsroot=$(shell cat CVS/Root)
+
+dist:
+	cvs tag -F $(TAG) &&\
+	cd $(TMP) &&\
+	unset CVSREAD; cvs -d $(cvsroot) export -r $(TAG) -d $(PACKAGE)-$(VERSION) $(cvsmodule) &&\
+	cd $(PACKAGE)-$(VERSION) &&\
+	make info $(AUTOLOADS) &&\
+	cd .. &&\
+	ztar $(PACKAGE)-$(VERSION) &&\
+	rm -rf $(PACKAGE)-$(VERSION)
+	mv $(TMP)/$(PACKAGE)-$(VERSION).tar.gz $(ftpdir)/
+	ln -sf $(PACKAGE)-$(VERSION).tar.gz $(ftpdir)/$(PACKAGE).tar.gz
+
+# arch-tag: 1ab314c8-3821-44fb-b533-dd58f5d75ba4
+Changes since 2.0:
+
+* inf-haskell uses ghci if hugs is absent.
+
+* Fix up some binding conflicts (C-c C-o in haskell-doc)
+
+* Many (hopefully minor) changes to the indentation.
+
+* New symbols in haskell-font-lock-symbols-alist.
+
+Changes since 1.45:
+
+* keybindings C-c <char> have been replaced by C-c C-<char> so as not
+  to collide with minor modes.
+
+* The following modules are now automatically activated without having to
+  add anything to haskell-mode-hook:
+  haskell-font-lock (just turn on global-font-lock-mode).
+  haskell-decl-scan (just bind `imenu' to some key).
+
+* In recent Emacsen, haskell-doc hooks into eldoc-mode.
+
+* haskell-hugs and haskell-ghci are superceded by inf-haskell.
+
+* Indentation rules have been improved when using layout inside parens/braces.
+
+* Symbols like -> and \ can be displayed as actual arrows and lambdas.
+  See haskell-font-lock-symbols.
+
+* Tweaks to the font-lock settings.  Among other things paren-matching
+  with things like \(x,y) should work correctly now.
+
+* New maintainer <monnier@gnu.org>.
+
+# arch-tag: e50204f2-98e4-438a-bcd1-a49afde5efa5
                                              -- and module names are coloured
                                              -- closer to ordinary code.
 
+recognize +++ infix :: Operator Declarations
+as `well` as = This Form
+(+) and this one = as well
+
+instance Show Toto where
+    fun1 arg1 = foo             -- FIXME: `fun1' should be highlighted.
+
+constStr = "hello \
+           \asdgfasgf\
+           \asf"
+
 {-
 map :: (a -> b) -> [a] -> [b]           -- Commenting out large sections of
 map f []     = []                       -- code can be misleading.  Coloured
 map f (x:xs) = f x : map f xs           -- comments reveal unused definitions.
 -}
+

haskell-decl-scan.el

 ;;; haskell-decl-scan.el --- Declaration scanning module for Haskell Mode
 
+;; Copyright (C) 2004, 2005  Free Software Foundation, Inc.
 ;; Copyright (C) 1997-1998 Graeme E Moss
 
 ;; Authors: 1997-1998 Graeme E Moss <gem@cs.york.ac.uk>
 ;; Keywords: declarations menu files Haskell
-;; Version: 1.2
-;; URL: http://www.cs.york.ac.uk/~gem/haskell-mode/decl-scan.html
+;; URL: http://cvs.haskell.org/cgi-bin/cvsweb.cgi/fptools/CONTRIB/haskell-modes/emacs/haskell-decl-scan.el?rev=HEAD
 
-;;; This file is not part of GNU Emacs.
+;; This file is not part of GNU Emacs.
 
 ;; This file is free software; you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
 ;;
 ;; If you have any problems or suggestions, after consulting the list
 ;; below, email gem@cs.york.ac.uk quoting the version of the library
-;; you are using, the version of emacs you are using, and a small
+;; you are using, the version of Emacs you are using, and a small
 ;; example of the problem or suggestion.  Note that this library
 ;; requires a reasonably recent version of Emacs.
 ;;
-;; Uses `imenu' under FSF Emacs, and `func-menu' under XEmacs.
+;; Uses `imenu' under Emacs, and `func-menu' under XEmacs.
 ;;
 ;; Version 1.2:
 ;;   Added support for LaTeX-style literate scripts.
 ;;   with spaces okay.
 ;;
 ;; . Would like to extend the goto functions given by `func-menu'
-;;   under XEmacs to FSF Emacs.  Would have to implement these
+;;   under XEmacs to Emacs.  Would have to implement these
 ;;   ourselves as `imenu' does not provide them.
 ;;
 ;; . `func-menu' uses its own syntax table when grabbing a declaration
 ;;   eg. "fib'" will be grabbed as "fib" since "'" is not a word or
 ;;   symbol constituent under the syntax table `func-menu' uses.
 
-;;; All functions/variables start with
-;;; `(turn-(on/off)-)haskell-decl-scan' or `haskell-ds-'.
+;; All functions/variables start with
+;; `(turn-(on/off)-)haskell-decl-scan' or `haskell-ds-'.
 
-;;; The imenu support is based on code taken from `hugs-mode',
-;;; thanks go to Chris Van Humbeeck.
+;; The imenu support is based on code taken from `hugs-mode',
+;; thanks go to Chris Van Humbeeck.
 
 ;; Version.
-(defconst haskell-decl-scan-version "1.1"
-  "haskell-decl-scan version number.")
+
+;;; Code:
+
+(require 'haskell-mode)
+
+(defconst haskell-decl-scan-version "1.9"
+  "Version number of haskell-decl-scan.")
 (defun haskell-decl-scan-version ()
   "Echo the current version of haskell-decl-scan in the minibuffer."
   (interactive)
 ;; As `cl' defines macros that `imenu' uses, we must require them at
 ;; compile time.
 (eval-when-compile
-  ;; `imenu' isn't used in XEmacs.
-  (if (not (string-match "Lucid\\|XEmacs" emacs-version))
-      (progn
-	(require 'cl)
-	(require 'imenu))))
-
-;; Are we running FSF Emacs or XEmacs?
-(defvar haskell-ds-running-xemacs
-  (string-match "Lucid\\|XEmacs" emacs-version)
-  "non-nil if we are running XEmacs, nil otherwise.")
+  (require 'cl)
+  (condition-case nil
+      (require 'imenu)
+    (error nil)))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; General declaration scanning functions.
 
-(defun haskell-ds-match-string (num)
-  "As `match-string' except that the string is stripped of properties."
-  (format "%s" (match-string num)))
+(defalias 'haskell-ds-match-string
+  (if (fboundp 'match-string-no-properties)
+      'match-string-no-properties
+    (lambda (num)
+      "As `match-string' except that the string is stripped of properties."
+      (format "%s" (match-string num)))))
 
 (defvar haskell-ds-start-keywords-re
   (concat "\\(\\<"
 	  "\\)\\>")
   "Keywords that may start a declaration.")
 
-(defvar haskell-ds-syntax-table nil
+(defvar haskell-ds-syntax-table
+  (let ((table (copy-syntax-table haskell-mode-syntax-table)))
+    (modify-syntax-entry ?\' "w" table)
+    (modify-syntax-entry ?_  "w" table)
+    (modify-syntax-entry ?\\ "_" table)
+    table)
   "Syntax table used for Haskell declaration scanning.")
 
-(if (not haskell-ds-syntax-table)
-    (progn
-      (setq haskell-ds-syntax-table (make-syntax-table))
-  (modify-syntax-entry ?\  " " haskell-ds-syntax-table)
-  (modify-syntax-entry ?\t " " haskell-ds-syntax-table)
-  (modify-syntax-entry ?\" "\"" haskell-ds-syntax-table)
-  (modify-syntax-entry ?\' "w" haskell-ds-syntax-table)
-  (modify-syntax-entry ?_  "w" haskell-ds-syntax-table)
-  (modify-syntax-entry ?\( "()" haskell-ds-syntax-table)
-  (modify-syntax-entry ?\) ")(" haskell-ds-syntax-table)
-  (modify-syntax-entry ?[  "(]" haskell-ds-syntax-table)
-  (modify-syntax-entry ?]  ")[" haskell-ds-syntax-table)
-  (modify-syntax-entry ?{  "(}1" haskell-ds-syntax-table)
-  (modify-syntax-entry ?}  "){4" haskell-ds-syntax-table)
-  (modify-syntax-entry ?-  "_ 23" haskell-ds-syntax-table)
-  (modify-syntax-entry ?\` "$`" haskell-ds-syntax-table)
-  (mapcar (lambda (x)
-            (modify-syntax-entry x "_" haskell-ds-syntax-table))
-          (concat "!#$%&*+./:<=>?@\\^|~"
-                  (haskell-enum-from-to ?\241 ?\277)
-                  "\327\367"))
-  (mapcar (lambda (x)
-            (modify-syntax-entry x "w" haskell-ds-syntax-table))
-          (concat (haskell-enum-from-to ?\300 ?\326)
-                  (haskell-enum-from-to ?\330 ?\337)
-                  (haskell-enum-from-to ?\340 ?\366)
-                  (haskell-enum-from-to ?\370 ?\377)))))
 
 (defun haskell-ds-get-variable (prefix)
   "Assuming point is looking at the regexp PREFIX followed by the
     ;; Return the result.
     result))
 
+(defun haskell-ds-bird-p ()
+  (if (boundp 'haskell-literate)
+      (eq haskell-literate 'bird) nil))
+
 (defun haskell-ds-backward-decl ()
   "Move point backward to the first character preceeding the current
 point that starts a top-level declaration.  A series of declarations
 declaration, and nil otherwise, ie. because point is at the beginning
 of the buffer and no declaration starts there."
   (interactive)
-  (haskell-ds-move-to-decl nil
-                           (if (boundp 'haskell-literate)
-                               (eq haskell-literate 'bird) nil)
-                           nil))
+  (haskell-ds-move-to-decl nil (haskell-ds-bird-p) nil))
 
 (defun haskell-ds-forward-decl ()
   "As `haskell-ds-backward-decl' but forward."
   (interactive)
-  (haskell-ds-move-to-decl t
-                           (if (boundp 'haskell-literate)
-                               (eq haskell-literate 'bird) nil)
-                           nil))
+  (haskell-ds-move-to-decl t (haskell-ds-bird-p) nil))
 
 (defun haskell-ds-generic-find-next-decl (bird-literate)
   "Find the name, position and type of the declaration at or after
 ;; Declaration scanning via `imenu'.
 
 (defun haskell-ds-create-imenu-index ()
-  "Non-literate Haskell version of `haskell-ds-generic-create-menu-index'."
-  (haskell-ds-generic-create-imenu-index nil))
-
-(defun literate-haskell-ds-create-imenu-index ()
-  "Bird-style literate Haskell version of
-`haskell-ds-generic-create-menu-index'."
-  (haskell-ds-generic-create-imenu-index t))
-
-(defun haskell-ds-generic-create-imenu-index (bird-literate)
-  "Function for finding `imenu' declarations in (BIRD-LITERATE) Haskell mode.
+  "Function for finding `imenu' declarations in Haskell mode.
 Finds all declarations (classes, variables, imports, instances and
 datatypes) in a Haskell file for the `imenu' package."
   ;; Each list has elements of the form `(INDEX-NAME . INDEX-POSITION)'.
   ;; These lists are nested using `(INDEX-TITLE . INDEX-ALIST)'.
-  (let* ((index-alist '())
+  (let* ((bird-literate (haskell-ds-bird-p))
+	 (index-alist '())
 	 (index-class-alist '())   ;; Classes
 	 (index-var-alist '())     ;; Variables
 	 (index-imp-alist '())     ;; Imports
 `haskell-ds-create-imenu-index'."
   (string< (car el1) (car el2)))
 
-(defun haskell-ds-imenu (bird-literate)
-  "Install `imenu' for (BIRD-LITERATE) Haskell scripts."
-  ;; Would prefer to toggle imenu but can't see how to turn it off...
-  (require 'imenu)
-  ;; In emacs-20's imenu we have to bind some functions first -- HWL
-  (if (and  (not haskell-ds-running-xemacs)
-	    (>= (string-to-number (substring emacs-version 0 2)) 20)
-	    (not (fboundp 'imenu-extract-index-name-function)))
-    (setq imenu-extract-index-name-function
-	  (if bird-literate (function literate-haskell-ds-create-imenu-index)
-	    (function haskell-ds-create-imenu-index))))
-  (setq imenu-create-index-function
-	(if bird-literate (function literate-haskell-ds-create-imenu-index)
-	  (function haskell-ds-create-imenu-index)))
+(defun haskell-ds-imenu ()
+  "Install `imenu' for Haskell scripts."
+  (setq imenu-create-index-function 'haskell-ds-create-imenu-index)
   (if (fboundp 'imenu-add-to-menubar)
       (imenu-add-to-menubar "Declarations")))
 
 
 (defun haskell-ds-func-menu-next (buffer)
   "Non-literate Haskell version of `haskell-ds-generic-func-menu-next'." 
-  (haskell-ds-generic-func-menu-next nil buffer)) 
-
-(defun literate-haskell-ds-func-menu-next (buffer)
-  "Bird-style literate Haskell version of `haskell-ds-generic-func-menu-next'."
-  (haskell-ds-generic-func-menu-next t buffer)) 
+  (haskell-ds-generic-func-menu-next (haskell-ds-bird-p) buffer)) 
 
 (defun haskell-ds-generic-func-menu-next (bird-literate buffer)
-  "Returns `(name . pos)' of next declaration."
+  "Return `(name . pos)' of next declaration."
   (set-buffer buffer)
   (let ((result (haskell-ds-generic-find-next-decl bird-literate)))
     (if result
 	       (name (car name-posns))
 	       (posns (cdr name-posns))
 	       (name-pos (cdr posns))
-	       ;(type (cdr result))
+               ;;(type (cdr result))
 	       )
 	  (cons ;(concat
 		 ;; func-menu has problems with spaces, and adding a
 		 ;; qualifying keyword will not allow the "goto fn"
 		 ;; functions to work properly.  Sigh.
-;		 (cond
-;		  ((eq type 'variable) "")
-;		  ((eq type 'datatype) "datatype ")
-;		  ((eq type 'class) "class ")
-;		  ((eq type 'import) "import ")
-;		  ((eq type 'instance) "instance "))
+		 ;; (cond
+		 ;;  ((eq type 'variable) "")
+		 ;;  ((eq type 'datatype) "datatype ")
+		 ;;  ((eq type 'class) "class ")
+		 ;;  ((eq type 'import) "import ")
+		 ;;  ((eq type 'instance) "instance "))
 		 name;)
 		name-pos))
       nil)))
   (concat "^" literate-haskell-ds-start-decl-re)
   "As `haskell-ds-func-menu-regexp' but for Bird-style literate scripts.")
 
-(defun haskell-ds-func-menu (bird-literate)
-  "Uses `func-menu' to establish declaration scanning for (BIRD-LITERATE)
-Haskell scripts."
+(defun haskell-ds-func-menu ()
+  "Use `func-menu' to establish declaration scanning for Haskell scripts."
   (require 'func-menu)
-  (make-local-variable 'fume-menubar-menu-name)
-  (setq fume-menubar-menu-name "Declarations")
-  (make-local-variable 'fume-function-name-regexp-alist)
-  (setq fume-function-name-regexp-alist
-	(if bird-literate
-            '((haskell-mode . literate-haskell-ds-func-menu-regexp))
-          '((haskell-mode . haskell-ds-func-menu-regexp))))
-  (make-local-variable 'fume-find-function-name-method-alist)
-  (setq fume-find-function-name-method-alist
-        (if bird-literate
-            '((haskell-mode . literate-haskell-ds-func-menu-next))
-          '((haskell-mode . haskell-ds-func-menu-next))))
+  (set (make-local-variable 'fume-menubar-menu-name) "Declarations")
+  (set (make-local-variable 'fume-function-name-regexp-alist)
+       (if (haskell-ds-bird-p)
+           '((haskell-mode . literate-haskell-ds-func-menu-regexp))
+         '((haskell-mode . haskell-ds-func-menu-regexp))))
+  (set (make-local-variable 'fume-find-function-name-method-alist)
+       '((haskell-mode . haskell-ds-func-menu-next)))
   (fume-add-menubar-entry)
   (local-set-key "\C-cl" 'fume-list-functions)
   (local-set-key "\C-cg" 'fume-prompt-function-goto)
 \\[fume-prompt-function-goto] prompts for a declaration to move to, and
 \\[fume-mouse-function-goto] moves to the declaration whose name is at point.
 
-This may link with `haskell-doc' (only for FSF Emacs currently).
+This may link with `haskell-doc' (only for Emacs currently).
 
 For non-literate and LaTeX-style literate scripts, we assume the
 common convention that top-level declarations start at the first
 Use `haskell-decl-scan-version' to find out what version this is."
   (interactive)
   (haskell-ds-keys)
-  (let ((bird-literate (if (boundp 'haskell-literate)
-                           (eq haskell-literate 'bird) nil)))
-    (if haskell-ds-running-xemacs
-        (haskell-ds-func-menu bird-literate)
-      (haskell-ds-imenu bird-literate)))
+  (if (fboundp 'imenu)
+      (haskell-ds-imenu)
+    (haskell-ds-func-menu))
   (run-hooks 'haskell-decl-scan-hook))
 
-;;; Provide ourselves:
+;; Provide ourselves:
 
 (provide 'haskell-decl-scan)
 
-;;; haskell-decl-scan ends here.
+;;; haskell-decl-scan.el ends here
 ;;; haskell-doc.el --- show function types in echo area
 
-;; Time-stamp: <Thu Dec 10 1998 17:26:21 Stardate: [-30]2203.42 hwloidl>
-
+;; Copyright (C) 2004, 2005  Free Software Foundation, Inc.
 ;; Copyright (C) 1997 Hans-Wolfgang Loidl
 
 ;; Author: Hans-Wolfgang Loidl <hwloidl@dcs.glasgow.ac.uk>
-;; Maintainer: Hans-Wolfgang Loidl <hwloidl@dcs.glasgow.ac.uk>
 ;; Temporary Maintainer and Hacker: Graeme E Moss <gem@cs.york.ac.uk>
 ;; Keywords: extensions, minor mode, language mode, Haskell
 ;; Created: 1997-06-17
-;; Revision: $Revision$
-;; FTP archive: /ftp@ftp.dcs.gla.ac.uk:/pub/glasgow-fp/authors/Hans_Loidl/Elisp/haskell-doc.el
-;; Status: Beta version
-
-;; $Id$
+;; URL: http://cvs.haskell.org/cgi-bin/cvsweb.cgi/fptools/CONTRIB/haskell-modes/emacs/haskell-doc.el?rev=HEAD
 
 ;;; Copyright:
 ;;  ==========
 ;;  ===========
 
 ;; This program shows the type of the Haskell function under the cursor in the
-;; minibuffer. It acts as a kind of "emacs background process", by regularly
+;; minibuffer.  It acts as a kind of "emacs background process", by regularly
 ;; checking the word under the cursor and matching it against a list of
 ;; prelude, library, local and global functions.
 
 ;; The preferred usage of this package is in combination with
 ;; `haskell-hugs-mode'.
 ;; In that case `haskell-doc-mode' checks an internal variable updated by
-;; `imenu' to access the types of all local functions. In `haskell-mode' this
-;; is not possible. However, types of prelude functions are still shown.
+;; `imenu' to access the types of all local functions.  In `haskell-mode' this
+;; is not possible.  However, types of prelude functions are still shown.
 
-;; To show types of global functions, i.e. functions defined in a module 
-;; imported by the current module, call the function 
-;; `turn-on-haskell-doc-global-types'. This automatically loads all modules
-;; and builds `imenu' tables to get the types of all functions (again this 
-;; currently requires `haskell-hugs-mode'). 
+;; To show types of global functions, i.e. functions defined in a module
+;; imported by the current module, call the function
+;; `turn-on-haskell-doc-global-types'.  This automatically loads all modules
+;; and builds `imenu' tables to get the types of all functions (again this
+;; currently requires `haskell-hugs-mode').
 ;; Note: The modules are loaded recursively, so you might pull in
 ;;       many modules by just turning on global function support.
 ;; This features is currently not very well supported.
 ;;  `haskell-doc-show-user-defined' (default: t)
 
 ;; If you want to define your own strings for some identifiers define an
-;; alist of (ID . STRING) and set `haskell-doc-show-user-defined' to t. 
+;; alist of (ID . STRING) and set `haskell-doc-show-user-defined' to t.
 ;; E.g:
 ;;
 ;;   (setq haskell-doc-show-user-defined t)
-;;   (setq haskell-doc-user-defined-ids 
-;;	(list 
+;;   (setq haskell-doc-user-defined-ids
+;;	(list
 ;;	   '("main" . "just another pathetic main function")
 ;;	   '("foo" . "a very dummy name")
 ;;	   '("bar" . "another dummy name")))
 
 ;;  The following two variables are useful to make the type fit on one line:
 ;;  If `haskell-doc-chop-off-context' is non-nil the context part of the type
-;;  of a local fct will be eliminated (default: t). 
-;;  If `haskell-doc-chop-off-fctname' is non-nil the function name is not 
+;;  of a local fct will be eliminated (default: t).
+;;  If `haskell-doc-chop-off-fctname' is non-nil the function name is not
 ;;  shown together with the type (default: nil).
 
 ;;; Internals:
 ;;  `haskell-doc-show-prelude'      ... toggle echoing of prelude id's types
 ;;  `haskell-doc-show-strategy'     ... toggle echoing of strategy id's types
 ;;  `haskell-doc-show-user-defined' ... toggle echoing of user def id's types
-;;  `haskell-doc-check-active' ... check whether haskell-doc is active via the 
-;;                                `post-command-idle-hook' (for testing); 
+;;  `haskell-doc-check-active' ... check whether haskell-doc is active via the
+;;                                `post-command-idle-hook' (for testing);
 ;;                                 Key: CTRL-c ESC-/
 
 ;;; ToDo:
 ;;  =====
 
-;;   - Fix byte-compile problems in `haskell-doc-prelude-types' for getArgs etc 
+;;   - Fix byte-compile problems in `haskell-doc-prelude-types' for getArgs etc
 ;;   - Write a parser for .hi files and make haskell-doc independent from
 ;;     hugs-mode. Read library interfaces via this parser.
 ;;   - Indicate kind of object with colours
 ;;; Bugs:
 ;;  =====
 
-;;   - Some prelude fcts aren't displayed properly. This might be due to a 
+;;   - Some prelude fcts aren't displayed properly. This might be due to a
 ;;     name clash of Haskell and Elisp functions (e.g. length) which
 ;;     confuses emacs when reading `haskell-doc-prelude-types'
 
 ;;; Changelog:
 ;;  ==========
-;;  $Log$
+;;  haskell-doc.el,v
+;;  Revision 1.16  2005/11/07 01:28:16  monnier
+;;  (haskell-doc-xemacs-p, haskell-doc-emacs-p)
+;;  (haskell-doc-message): Remove.
+;;  (haskell-doc-is-id-char-at): Remove.
+;;  (haskell-doc-get-current-word): Rewrite.
+;;
+;;  Revision 1.15  2005/11/04 17:11:12  monnier
+;;  Add arch-tag.
+;;
+;;  Revision 1.14  2005/08/24 11:36:32  monnier
+;;  (haskell-doc-message): Paren typo.
+;;
+;;  Revision 1.13  2005/08/23 19:23:27  monnier
+;;  (haskell-doc-show-type): Assume that the availability
+;;  of display-message won't change at runtime.
+;;
+;;  Revision 1.12  2005/07/18 21:04:14  monnier
+;;  (haskell-doc-message): Remove.
+;;  (haskell-doc-show-type): inline it.  Do nothing for if there's no doc to show.
+;;
+;;  Revision 1.11  2004/12/10 17:33:18  monnier
+;;  (haskell-doc-minor-mode-string): Make it dynamic.
+;;  (haskell-doc-install-keymap): Remove conflicting C-c C-o binding.
+;;  (haskell-doc-mode): Make a nil arg turn the mode ON.
+;;  (turn-on-haskell-doc-mode): Make it an alias for haskell-doc-mode.
+;;  (haskell-doc-mode): Don't touch haskell-doc-minor-mode-string.
+;;  (haskell-doc-show-global-types): Don't touch
+;;  haskell-doc-minor-mode-string.  Call haskell-doc-make-global-fct-index.
+;;  (haskell-doc-check-active): Fix message.
+;;  (define-key-after): Don't define.
+;;  (haskell-doc-install-keymap): Check existence of define-key-after.
+;;
+;;  Revision 1.10  2004/11/25 23:03:23  monnier
+;;  (haskell-doc-sym-doc): Make even the last char bold.
+;;
+;;  Revision 1.9  2004/11/24 22:14:36  monnier
+;;  (haskell-doc-install-keymap): Don't blindly assume there's a Hugs menu.
+;;
+;;  Revision 1.8  2004/11/22 10:45:35  simonmar
+;;  Fix type of getLine
+;;
+;;  Revision 1.7  2004/10/14 22:27:47  monnier
+;;  (turn-off-haskell-doc-mode, haskell-doc-current-info): Don't autoload.
+;;
+;;  Revision 1.6  2004/10/13 22:45:22  monnier
+;;  (haskell-doc): New group.
+;;  (haskell-doc-show-reserved, haskell-doc-show-prelude)
+;;  (haskell-doc-show-strategy, haskell-doc-show-user-defined)
+;;  (haskell-doc-chop-off-context, haskell-doc-chop-off-fctname):
+;;  Make them custom vars.
+;;  (haskell-doc-keymap): Declare and fill it right there.
+;;  (haskell-doc-mode): Simplify.
+;;  (haskell-doc-toggle-var): Make it into what it was supposed to be.
+;;  (haskell-doc-mode-print-current-symbol-info): Simplify.
+;;  (haskell-doc-current-info): New autoloaded function.
+;;  (haskell-doc-sym-doc): New fun extracted from haskell-doc-show-type.
+;;  (haskell-doc-show-type): Use it.
+;;  (haskell-doc-wrapped-type-p): Remove unused var `lim'.
+;;  (haskell-doc-forward-sexp-safe, haskell-doc-current-symbol): Remove.  Unused.
+;;  (haskell-doc-visit-home): Don't require ange-ftp, it's autoloaded.
+;;  (haskell-doc-install-keymap): Simplify.
+;;
+;;  Revision 1.5  2003/01/09 11:56:26  simonmar
+;;  Patches from Ville Skytt� <scop@xemacs.org>, the XEmacs maintainer of
+;;  the haskell-mode:
+;;
+;;   - Make the auto-mode-alist modifications autoload-only.
+;;
 ;;  Revision 1.4  2002/10/14 09:55:03  simonmar
 ;;  Patch to update the Prelude/libraries function names and to remove
 ;;  support for older versions of Haskell.
 ;;; Code:
 ;;  =====
 
-;@menu
-;* Constants and Variables::	
-;* Install as minor mode::	
-;* Menubar Support::		
-;* Haskell Doc Mode::		
-;* Switch it on or off::	
-;* Check::			
-;* Top level function::		
-;* Mouse interface::		
-;* Print fctsym::		
-;* Movement::			
-;* Bug Reports::		
-;* Visit home site::		
-;* Index::			
-;* Token::			
-;@end menu
+;;@menu
+;;* Constants and Variables::
+;;* Install as minor mode::
+;;* Menubar Support::
+;;* Haskell Doc Mode::
+;;* Switch it on or off::
+;;* Check::
+;;* Top level function::
+;;* Mouse interface::
+;;* Print fctsym::
+;;* Movement::
+;;* Bug Reports::
+;;* Visit home site::
+;;* Index::
+;;* Token::
+;;@end menu
 
-;@node top, Constants and Variables, (dir), (dir)
-;@top
+;;@node top, Constants and Variables, (dir), (dir)
+;;@top
 
-;@node Constants and Variables, Install as minor mode, top, top
-;@section Constants and Variables
+;;@node Constants and Variables, Install as minor mode, top, top
+;;@section Constants and Variables
 
-;@menu
-;* Emacs portability::		
-;* Maintenance stuff::		
-;* Mode Variable::		
-;* Variables::			
-;* Prelude types::		
-;* Test membership::		
-;@end menu
+;;@menu
+;;* Emacs portability::
+;;* Maintenance stuff::
+;;* Mode Variable::
+;;* Variables::
+;;* Prelude types::
+;;* Test membership::
+;;@end menu
 
-;@node Emacs portability, Maintenance stuff, Constants and Variables, Constants and Variables
-;@subsection Emacs portability
+;;@node Emacs portability, Maintenance stuff, Constants and Variables, Constants and Variables
+;;@subsection Emacs portability
 
-(defconst haskell-doc-xemacs-p (string-match "XEmacs\\|Lucid" emacs-version)
-  "Running under XEmacs?")
+(defgroup haskell-doc nil
+  "Show Haskell function types in echo area."
+  :group 'haskell
+  :prefix "haskell-doc-")
 
-(defconst haskell-doc-emacs-p (and (or (string-match "^19" emacs-version)
-				       (string-match "^20" emacs-version))
-				(not haskell-doc-xemacs-p))
-  "Running under Emacs?")
+;;@node Maintenance stuff, Mode Variable, Emacs portability, Constants and Variables
+;;@subsection Maintenance stuff
 
-;@node Maintenance stuff, Mode Variable, Emacs portability, Constants and Variables
-;@subsection Maintenance stuff
-
-(defconst haskell-doc-version "$Revision$"
+(defconst haskell-doc-version "1.16"
  "Version of `haskell-doc-mode' as RCS Revision.")
 
-(defconst haskell-doc-maintainer "Hans-Wolfgang Loidl <hwloidl@dcs.glasgow.ac.uk>"
+(defconst haskell-doc-maintainer
+  "Hans-Wolfgang Loidl <hwloidl@dcs.glasgow.ac.uk>"
   "Maintainer of `haskell-doc-mode'.")
 
-(defconst haskell-doc-ftp-site "/ftp@ftp.dcs.gla.ac.uk:/pub/glasgow-fp/authors/Hans_Loidl/Elisp/"
+(defconst haskell-doc-ftp-site
+  "/ftp@ftp.dcs.gla.ac.uk:/pub/glasgow-fp/authors/Hans_Loidl/Elisp/"
   "Main FTP site with latest version of `haskell-doc-mode' and sample files.")
 
-;@node Mode Variable, Variables, Maintenance stuff, Constants and Variables
-;@subsection Mode Variable
+;;@node Mode Variable, Variables, Maintenance stuff, Constants and Variables
+;;@subsection Mode Variable
 
-;;;###autoload
 (defvar haskell-doc-mode nil
   "*If non-nil, show the type of the function near point or a related comment.
 
 `haskell-doc-show-reserved' is non-nil show a one line summary
 of the syntax.
 
-If the identifier near point is a Prelude or one of the standard library 
+If the identifier near point is a Prelude or one of the standard library
 functions and `haskell-doc-show-prelude' is non-nil show its type.
 
 If the identifier near point is local \(i.e. defined in this module\) check
 the `imenu' list of functions for the type. This obviously requires that
 your language mode uses `imenu' \(`haskell-hugs-mode' 0.6 for example\).
 
-If the identifier near point is global \(i.e. defined in an imported module\) 
-and the variable `haskell-doc-show-global-types' is non-nil show the type of its 
+If the identifier near point is global \(i.e. defined in an imported module\)
+and the variable `haskell-doc-show-global-types' is non-nil show the type of its
 function.
 
 If the identifier near point is a standard strategy or a function, type related
 If you're not interested in that just turn it off.
 
 If the identifier near point is a user defined function that occurs as key
-in the alist `haskell-doc-user-defined-ids' and the variable 
+in the alist `haskell-doc-user-defined-ids' and the variable
 `haskell-doc-show-user-defined' is non-nil show the type of the function.
 
 This variable is buffer-local.")
 This variable is buffer-local.")
 (make-variable-buffer-local 'haskell-doc-index)
 
-(defvar haskell-doc-show-global-types nil
- "*If non-nil, search for the types of global functions by loading the files.
-This variable is buffer-local.")
+(defcustom haskell-doc-show-global-types nil
+  "If non-nil, search for the types of global functions by loading the files.
+This variable is buffer-local."
+  :type 'boolean)
 (make-variable-buffer-local 'haskell-doc-show-global-types)
 
-(defvar haskell-doc-show-reserved t
- "*If non-nil, show a documentation string for reserved ids.
-This variable is buffer-local.")
+(defcustom haskell-doc-show-reserved t
+  "If non-nil, show a documentation string for reserved ids.
+This variable is buffer-local."
+  :type 'boolean)
 (make-variable-buffer-local 'haskell-doc-show-reserved)
 
-(defvar haskell-doc-show-prelude t
- "*If non-nil, show a documentation string for prelude functions.
-This variable is buffer-local.")
+(defcustom haskell-doc-show-prelude t
+  "If non-nil, show a documentation string for prelude functions.
+This variable is buffer-local."
+  :type 'boolean)
 (make-variable-buffer-local 'haskell-doc-show-prelude)
 
-(defvar haskell-doc-show-strategy t
- "*If non-nil, show a documentation string for strategies.
-This variable is buffer-local.")
+(defcustom haskell-doc-show-strategy t
+  "If non-nil, show a documentation string for strategies.
+This variable is buffer-local."
+  :type 'boolean)
 (make-variable-buffer-local 'haskell-doc-show-strategy)
 
-(defvar haskell-doc-show-user-defined t
- "*If non-nil, show a documentation string for user defined ids.
-This variable is buffer-local.")
+(defcustom haskell-doc-show-user-defined t
+  "If non-nil, show a documentation string for user defined ids.
+This variable is buffer-local."
+  :type 'boolean)
 (make-variable-buffer-local 'haskell-doc-show-user-defined)
 
-(defvar haskell-doc-chop-off-context t
- "*If non-nil eliminate the context part in a Haskell type.")
+(defcustom haskell-doc-chop-off-context t
+ "If non-nil eliminate the context part in a Haskell type."
+ :type 'boolean)
 
-(defvar haskell-doc-chop-off-fctname nil
- "*If non-nil omit the function name and show only the type.")
+(defcustom haskell-doc-chop-off-fctname nil
+  "If non-nil omit the function name and show only the type."
+  :type 'boolean)
 
 (defvar haskell-doc-search-distance 40  ; distance in characters
  "*How far to search when looking for the type declaration of fct under cursor.")
 
-;@node Variables, Prelude types, Mode Variable, Constants and Variables
-;@subsection Variables
+;;@node Variables, Prelude types, Mode Variable, Constants and Variables
+;;@subsection Variables
 
 (defvar haskell-doc-idle-delay 0.50
   "*Number of seconds of idle time to wait before printing.
 It is probably best to manipulate this data structure with the commands
 `haskell-doc-add-command' and `haskell-doc-remove-command'.")
 
-;(cond ((null haskell-doc-mode-message-commands)
-;       ;; If you increase the number of buckets, keep it a prime number.
-;       (setq haskell-doc-mode-message-commands (make-vector 31 0))
-;       (let ((list '("self-insert-command"
-;                     "next-"         "previous-"
-;                     "forward-"      "backward-"
-;                     "beginning-of-" "end-of-"
-;                     "goto-"
-;                     "recenter"
-;                     "scroll-"))
-;             (syms nil))
-;         (while list
-;           (setq syms (all-completions (car list) obarray 'fboundp))
-;           (setq list (cdr list))
-;           (while syms
-;             (set (intern (car syms) haskell-doc-mode-message-commands) t)
-;             (setq syms (cdr syms)))))))
+;;(cond ((null haskell-doc-mode-message-commands)
+;;       ;; If you increase the number of buckets, keep it a prime number.
+;;       (setq haskell-doc-mode-message-commands (make-vector 31 0))
+;;       (let ((list '("self-insert-command"
+;;                     "next-"         "previous-"
+;;                     "forward-"      "backward-"
+;;                     "beginning-of-" "end-of-"
+;;                     "goto-"
+;;                     "recenter"
+;;                     "scroll-"))
+;;             (syms nil))
+;;         (while list
+;;           (setq syms (all-completions (car list) obarray 'fboundp))
+;;           (setq list (cdr list))
+;;           (while syms
+;;             (set (intern (car syms) haskell-doc-mode-message-commands) t)
+;;             (setq syms (cdr syms)))))))
 
 ;; Bookkeeping; the car contains the last symbol read from the buffer.
 ;; The cdr contains the string last displayed in the echo area, so it can
 ;; be printed again if necessary without reconsing.
 (defvar haskell-doc-last-data '(nil . nil))
 
-(defvar haskell-doc-minor-mode-string " Doc"              ; " Haskell-Doc"
+(defvar haskell-doc-minor-mode-string
+  '(haskell-doc-show-global-types " DOC" " Doc")
   "*String to display in mode line when Haskell-Doc Mode is enabled.")
 
 (defconst haskell-doc-varlist
   (list
-   'haskell-doc-xemacs-p
-   'haskell-doc-emacs-p
    'haskell-doc-version
    'haskell-doc-mode
    'haskell-doc-mode-hook
   )
   "List of variables sent via `haskell-doc-submit-bug-report'.")
 
-;@node Prelude types, Test membership, Variables, Constants and Variables
-;@subsection Prelude types
+;;@node Prelude types, Test membership, Variables, Constants and Variables
+;;@subsection Prelude types
 
-;@cindex haskell-doc-reserved-ids
+;;@cindex haskell-doc-reserved-ids
 
 (defvar haskell-doc-reserved-ids
  (list
  )
  "An alist of reserved identifiers and a string describing the construct they are used in.")
 
-;@cindex haskell-doc-prelude-types
+;;@cindex haskell-doc-prelude-types
 
 (defvar haskell-doc-prelude-types
   (list
    '("gcd" . "(Integral a) => a -> a -> a")
    '("getChar" . "IO Char")
    '("getContents" . "IO String")
-   '("getLine" . "IO Char")
+   '("getLine" . "IO String")
    '("head" . "[a] -> a")
    '("id" . "a -> a")
    '("init" . "[a] -> [a]")
    '("getStdRandom" . "(StdGen -> (a, StdGen)) -> IO a"))
   "alist of prelude functions and their types.")
 
-;@cindex haskell-doc-strategy-ids
+;;@cindex haskell-doc-strategy-ids
 
 (defvar haskell-doc-strategy-ids
  (list
 (defvar haskell-doc-user-defined-ids nil
  "alist of functions and strings defined by the user.")
 
-;@node Test membership,  , Prelude types, Constants and Variables
-;@subsection Test membership
+;;@node Test membership,  , Prelude types, Constants and Variables
+;;@subsection Test membership
 
-;@cindex haskell-doc-is-of
+;;@cindex haskell-doc-is-of
 (defsubst haskell-doc-is-of (fn types)
   "Check whether FN is one of the functions in the alist TYPES and return the type."
   (assoc fn types) )
 
-;@node Install as minor mode, Menubar Support, Constants and Variables, top
-;@section Install as minor mode
+;;@node Install as minor mode, Menubar Support, Constants and Variables, top
+;;@section Install as minor mode
 
 ;; Put this minor mode on the global minor-mode-alist.
 (or (assq 'haskell-doc-mode (default-value 'minor-mode-alist))
                   (append (default-value 'minor-mode-alist)
                           '((haskell-doc-mode haskell-doc-minor-mode-string)))))
 
-;; In emacs 19.29 and later, and XEmacs 19.13 and later, all messages are
-;; recorded in a log.  Do not put haskell-doc messages in that log since
-;; they are Legion.
+
+;;@node Menubar Support, Haskell Doc Mode, Install as minor mode, top
+;;@section Menubar Support
 
-;@cindex haskell-doc-message
-
-(defmacro haskell-doc-message (&rest args)
-  (if (fboundp 'display-message)
-      ;; XEmacs 19.13 way of preventing log messages.
-      ;(list 'display-message '(quote no-log) (apply 'list 'format args))
-      ;; XEmacs 19.15 seems to be a bit different
-      (list 'display-message '(quote message) (apply 'list 'format args))
-    (list 'let (list (list 'message-log-max 'nil))
-          (apply 'list 'message args))))
-
-
-;@node Menubar Support, Haskell Doc Mode, Install as minor mode, top
-;@section Menubar Support
-
-; get imenu
+;; get imenu
 (require 'imenu)
 
-; a dummy definition needed for xemacs (I know, it's horrible :-(
-(if (and (string-match "XEmacs" emacs-version)
-	 (not (functionp 'define-key-after)))
-  (defun define-key-after (map seq con name)))
+;; a dummy definition needed for xemacs (I know, it's horrible :-(
 
-;@cindex haskell-doc-install-keymap
+;;@cindex haskell-doc-install-keymap
+
+(defvar haskell-doc-keymap
+  (let ((map (make-sparse-keymap)))
+    (define-key map [visit]
+      '("Visit FTP home site" . haskell-doc-visit-home))
+    (define-key map [submit]
+      '("Submit bug report" . haskell-doc-submit-bug-report))
+    (define-key map [dummy] '("---" . nil))
+    (define-key map [make-index]
+      '("Make global fct index" . haskell-doc-make-global-fct-index))
+    (define-key map [global-types-on]
+      '("Toggle display of global types" . haskell-doc-show-global-types))
+    (define-key map [strategy-on]
+      '("Toggle display of strategy ids" . haskell-doc-show-strategy))
+    (define-key map [user-defined-on]
+      '("Toggle display of user defined ids" . haskell-doc-show-user-defined))
+    (define-key map [prelude-on]
+      '("Toggle display of prelude functions" . haskell-doc-show-prelude))
+    (define-key map [reserved-ids-on]
+      '("Toggle display of reserved ids" . haskell-doc-show-reserved))
+    (define-key map [haskell-doc-on]
+      '("Toggle haskell-doc mode" . haskell-doc-mode))
+    map))
 
 (defun haskell-doc-install-keymap ()
   "Install a menu for `haskell-doc-mode' as a submenu of \"Hugs\"."
- (interactive)
- ; define a keymap `haskell-doc-keymap' for the derive menu
- (if nil ; (keymapp haskell-doc-keymap)
-       nil
-     (setq haskell-doc-keymap (make-sparse-keymap))
-     (define-key haskell-doc-keymap [visit]
-       '("Visit FTP home site" . haskell-doc-visit-home))
-     (define-key haskell-doc-keymap [submit]
-       '("Submit bug report" . haskell-doc-submit-bug-report))
-     (define-key haskell-doc-keymap [dummy]
-       '("---" . nil))
-     (define-key haskell-doc-keymap [make-index]
-       '("Make global fct index" . haskell-doc-make-global-fct-index))
-     (define-key haskell-doc-keymap [global-types-on]
-       '("Toggle display of global types" . haskell-doc-show-global-types))
-     (define-key haskell-doc-keymap [strategy-on]
-       '("Toggle display of strategy ids" . haskell-doc-show-strategy))
-     (define-key haskell-doc-keymap [user-defined-on]
-       '("Toggle display of user defined ids" . haskell-doc-show-user-defined))
-     (define-key haskell-doc-keymap [prelude-on]
-       '("Toggle display of prelude functions" . haskell-doc-show-prelude))
-     (define-key haskell-doc-keymap [reserved-ids-on]
-       '("Toggle display of reserved ids" . haskell-doc-show-reserved))
-     (define-key haskell-doc-keymap [haskell-doc-on]
-       '("Toggle haskell-doc mode" . haskell-doc-mode))
-  )
-
- ; add the menu to the hugs menu as last entry
- (cond 
-  ((eq major-mode 'haskell-hugs-mode)
-   (let ((hugsmap (lookup-key haskell-hugs-mode-map [menu-bar Hugs])))
-	 (if (and (not haskell-doc-xemacs-p) ; XEmacs has problems here
-		  (not (lookup-key hugsmap [haskell-doc])))
-	     (define-key-after hugsmap [haskell-doc] (cons "Haskell-doc" haskell-doc-keymap)
-	       [Haskell-doc mode]))
-     ; add shortcuts for these commands
-     (define-key haskell-hugs-mode-map "\C-c\e/" 'haskell-doc-check-active) ; for testing 
-     (define-key haskell-hugs-mode-map "\C-c\C-o" 'haskell-doc-mode) 
-     (if (not haskell-doc-xemacs-p) 
-	 (define-key haskell-hugs-mode-map [C-S-M-mouse-3] 'haskell-doc-ask-mouse-for-type))))
-  ((eq major-mode 'haskell-mode)
-   ; add shortcuts for these commands
-   (local-set-key "\C-c\e/" 'haskell-doc-check-active) ; for testing 
-   (local-set-key "\C-c\C-o" 'haskell-doc-mode) 
-   (if (not haskell-doc-xemacs-p)
-       (local-set-key [C-S-M-mouse-3] 'haskell-doc-ask-mouse-for-type)) ) ))
+  (interactive)
+  ;; Add the menu to the hugs menu as last entry.
+  (let ((hugsmap (lookup-key (current-local-map) [menu-bar Hugs])))
+    (if (not (or (featurep 'xemacs) ; XEmacs has problems here
+		 (not (keymapp hugsmap))
+		 (lookup-key hugsmap [haskell-doc])))
+	(if (functionp 'define-key-after)
+	    (define-key-after hugsmap [haskell-doc]
+	      (cons "Haskell-doc" haskell-doc-keymap)
+	      [Haskell-doc mode]))))
+  ;; Add shortcuts for these commands.
+  (local-set-key "\C-c\e/" 'haskell-doc-check-active)
+  ;; Conflicts with the binding of haskell-insert-otherwise.
+  ;; (local-set-key "\C-c\C-o" 'haskell-doc-mode)
+  (local-set-key [(control shift meta mouse-3)]
+		 'haskell-doc-ask-mouse-for-type))
 
 
-;@node Haskell Doc Mode, Switch it on or off, Menubar Support, top
-;@section Haskell Doc Mode
+;;@node Haskell Doc Mode, Switch it on or off, Menubar Support, top
+;;@section Haskell Doc Mode
 
-;@cindex haskell-doc-mode
+;;@cindex haskell-doc-mode
 
 ;;;###autoload
-(defun haskell-doc-mode (&optional prefix)
+(defun haskell-doc-mode (&optional arg)
   "Enter `haskell-doc-mode' for showing fct types in the echo area.
 See variable docstring."
-  (interactive "P")
+  (interactive (list (or current-prefix-arg 'toggle)))
 
   ;; Make sure it's on the post-command-idle-hook if defined, otherwise put
   ;; it on post-command-hook.  The former first appeared in Emacs 19.30.
   (setq haskell-doc-mode
-  	 (if prefix
-  	     (or (listp prefix);; C-u alone
-  		 (> (prefix-numeric-value prefix) 0))
-  	   (not haskell-doc-mode)))
+	(cond
+	 ((eq arg 'toggle) (not haskell-doc-mode))
+	 (arg (> (prefix-numeric-value arg) 0))
+	 (t)))
 
-  (and haskell-doc-mode-hook
-       haskell-doc-mode
-       (run-hooks 'haskell-doc-mode-hook))
+  (cond
+   (haskell-doc-mode
+    ;; Turning the mode ON.
 
-  ;; ToDo: replace binding of `post-command-idle-hook' by `run-with-idle-timer'
-  (and haskell-doc-mode
-       (not (memq 'haskell-doc-mode-print-current-symbol-info 
-		  (if (boundp 'post-command-idle-hook)
-		     post-command-idle-hook
-		   post-command-hook)))
-       (add-hook (if (boundp 'post-command-idle-hook)
+    ;; ToDo: replace binding of `post-command-idle-hook' by
+    ;; `run-with-idle-timer'
+    (add-hook (if (boundp 'post-command-idle-hook)
+		  'post-command-idle-hook
+		'post-command-hook)
+	      'haskell-doc-mode-print-current-symbol-info nil 'local)
+    (and haskell-doc-show-global-types
+	 (haskell-doc-make-global-fct-index)) ; build type index for global fcts
+
+    (haskell-doc-install-keymap)
+
+    (run-hooks 'haskell-doc-mode-hook))
+
+   ((not haskell-doc-mode)
+
+    (remove-hook (if (boundp 'post-command-idle-hook)
 		     'post-command-idle-hook
 		   'post-command-hook)
-		 'haskell-doc-mode-print-current-symbol-info))
-
-  (and (not haskell-doc-mode)
-       (memq 'haskell-doc-mode-print-current-symbol-info 
-	     (if (boundp 'post-command-idle-hook)
-			post-command-idle-hook
-		   post-command-hook))
-       (remove-hook (if (boundp 'post-command-idle-hook)
-			'post-command-idle-hook
-		   'post-command-hook)
-		 'haskell-doc-mode-print-current-symbol-info))
-
-  (and haskell-doc-mode
-       haskell-doc-show-global-types
-       (progn
-	 (setq haskell-doc-minor-mode-string " Haskell-DOC")
-	 (haskell-doc-make-global-fct-index))  ; build type index for global fcts
-       (setq haskell-doc-minor-mode-string " Haskell-Doc"))
-
-  (if haskell-doc-mode
-      (haskell-doc-install-keymap))
+		 'haskell-doc-mode-print-current-symbol-info 'local)))
 
   (and (interactive-p)
-       (if haskell-doc-mode
-           (message "haskell-doc-mode is enabled")
-         (message "haskell-doc-mode is disabled")))
+       (message "haskell-doc-mode is %s"
+		(if haskell-doc-mode "enabled" "disabled")))
   haskell-doc-mode)
 
-;;@cindex haskell-doc-show-global-types
-
-;;;;###autoload
-;(defun haskell-doc-show-global-types (&optional prefix)
-;  "*If non-nil, then enable display of global types in `haskell-doc-mode'."
-;  (interactive "P")
-;  ;; toggle mode or set it based on prefix value
-;  (setq haskell-doc-show-global-types
-;	(if prefix
-;	    (>= (prefix-numeric-value prefix) 0)
-;	  (not haskell-doc-show-global-types)))
-
-;  (cond (haskell-doc-show-global-types
-;	 ;; set mode string to reflect value of `haskell-doc-show-global-types'
-;	 (setq haskell-doc-minor-mode-string " Haskell-DOC")
-;	 ;; build index (note: this can be quite expensive)
-;	 (haskell-doc-make-global-fct-index))
-;	(t
-;	 (setq haskell-doc-minor-mode-string " Haskell-Doc")) ) )
-
-
 (defmacro haskell-doc-toggle-var (id prefix)
   ;; toggle variable or set it based on prefix value
-  (setq id
-	(if prefix
-	    (>= (prefix-numeric-value prefix) 0)
-	  (not id))) )
+  `(setq ,id
+	 (if ,prefix
+	     (>= (prefix-numeric-value ,prefix) 0)
+	   (not ,id))) )
 
-;@cindex haskell-doc-show-global-types
+;;@cindex haskell-doc-show-global-types
 (defun haskell-doc-show-global-types (&optional prefix)
   "Turn on global types information in `haskell-doc-mode'."
   (interactive "P")
   (haskell-doc-toggle-var haskell-doc-show-global-types prefix)
   (if haskell-doc-show-global-types
-      (setq haskell-doc-minor-mode-string " Haskell-DOC")
-    (setq haskell-doc-minor-mode-string " Haskell-Doc")) )
+      (haskell-doc-make-global-fct-index)))
 
-;@cindex haskell-doc-show-reserved
+;;@cindex haskell-doc-show-reserved
 (defun haskell-doc-show-reserved (&optional prefix)
   "Toggle the automatic display of a doc string for reserved ids."
   (interactive "P")
   (haskell-doc-toggle-var haskell-doc-show-reserved prefix))
 
-;@cindex haskell-doc-show-prelude
+;;@cindex haskell-doc-show-prelude
 (defun haskell-doc-show-prelude (&optional prefix)
   "Toggle the automatic display of a doc string for reserved ids."
   (interactive "P")
   (haskell-doc-toggle-var haskell-doc-show-prelude prefix))
 
-;@cindex haskell-doc-show-strategy
+;;@cindex haskell-doc-show-strategy
 (defun haskell-doc-show-strategy (&optional prefix)
   "Toggle the automatic display of a doc string for strategy ids."
   (interactive "P")
   (haskell-doc-toggle-var haskell-doc-show-strategy prefix))
 
-;@cindex haskell-doc-show-user-defined
+;;@cindex haskell-doc-show-user-defined
 (defun haskell-doc-show-user-defined (&optional prefix)
   "Toggle the automatic display of a doc string for user defined ids."
   (interactive "P")
   (haskell-doc-toggle-var haskell-doc-show-user-defined prefix))
 
-;@node Switch it on or off, Check, Haskell Doc Mode, top
-;@section Switch it on or off
+;;@node Switch it on or off, Check, Haskell Doc Mode, top
+;;@section Switch it on or off
 
-;@cindex turn-on-haskell-doc-mode
+;;@cindex turn-on-haskell-doc-mode
 
 ;;;###autoload
-(defun turn-on-haskell-doc-mode ()
-  "Unequivocally turn on `haskell-doc-mode' (see variable documentation)."
-  (interactive)
-  (haskell-doc-mode 1))
+(defalias 'turn-on-haskell-doc-mode 'haskell-doc-mode)
 
-;@cindex  turn-off-haskell-doc-mode
+;;@cindex  turn-off-haskell-doc-mode
 
-;;;###autoload
 (defun turn-off-haskell-doc-mode ()
   "Unequivocally turn off `haskell-doc-mode' (see variable documentation)."
   (interactive)
   (haskell-doc-mode 0))
 
-;@node Check, Top level function, Switch it on or off, top
-;@section Check
+;;@node Check, Top level function, Switch it on or off, top
+;;@section Check
 
-;@cindex haskell-doc-check-active
+;;@cindex haskell-doc-check-active
 
 (defun haskell-doc-check-active ()
- "Check whether the print function is hooked in. 
-Should be the same as the value of `haskell-doc-mode' but alas currently it 
+  "Check whether the print function is hooked in.
+Should be the same as the value of `haskell-doc-mode' but alas currently it
 is not."
- (interactive)
- (message 
-  (if (memq 'haskell-doc-mode-print-current-symbol-info 
-	    (if (boundp 'post-command-idle-hook)
-		post-command-idle-hook
-	      post-command-hook))
-      "haskell-doc is ACTIVE"
-    "haskell-doc is not ACTIVE \(Use C-u C-c C-o to turn it on\)")))
+  (interactive)
+  (message
+   (if (memq 'haskell-doc-mode-print-current-symbol-info
+	     (if (boundp 'post-command-idle-hook)
+		 post-command-idle-hook
+	       post-command-hook))
+       "haskell-doc is ACTIVE"
+     (substitute-command-keys
+      "haskell-doc is not ACTIVE \(Use C-u \\[haskell-doc-mode] to turn it on\)"))))
 
-;@node Top level function, Mouse interface, Check, top
-;@section Top level function
+;;@node Top level function, Mouse interface, Check, top
+;;@section Top level function
 
-;@cindex haskell-doc-mode-print-current-symbol-info
+;;@cindex haskell-doc-mode-print-current-symbol-info
 ;; This is the function hooked into the elisp command engine
 (defun haskell-doc-mode-print-current-symbol-info ()
- "Print the type of the symbol under the cursor. 
+ "Print the type of the symbol under the cursor.
 
 This function is hooked into the `post-command-idle-hook' to print the type
-automatically if `haskell-doc-mode' is turned on. It can also be called 
+automatically if `haskell-doc-mode' is turned on. It can also be called
 directly to ask for the type of a function."
   (interactive)
   (and haskell-doc-mode
        ;; Having this mode operate in the minibuffer makes it impossible to
        ;; see what you're doing.
        (not (eq (selected-window) (minibuffer-window)))
-       ; take a nap
+       ;; take a nap
        (sit-for haskell-doc-idle-delay)
-       ; good morning! read the word under the cursor for breakfast
-       (let ((current-symbol (haskell-doc-get-current-word)) ); (haskell-doc-current-symbol)) )
-             ; (current-fnsym  (haskell-doc-fnsym-in-current-sexp)))
-	 (haskell-doc-show-type current-symbol)) ))
+       ;; good morning! read the word under the cursor for breakfast
+       (haskell-doc-show-type)))
+       ;; ;; ToDo: find surrounding fct
+       ;; (cond ((eq current-symbol current-fnsym)
+       ;;        (haskell-doc-show-type current-fnsym))
+       ;;       (t
+       ;;        (or nil ; (haskell-doc-print-var-docstring current-symbol)
+       ;;            (haskell-doc-show-type current-fnsym)))))))
 
-;	 ; ToDo: find surrounding fct
-;         (cond ((eq current-symbol current-fnsym)
-;                (haskell-doc-show-type current-fnsym))
-;               (t
-;                (or nil ; (haskell-doc-print-var-docstring current-symbol)
-;                    (haskell-doc-show-type current-fnsym)))))))
+(defun haskell-doc-current-info ()
+  "Return the info about symbol at point.
+Meant for `eldoc-print-current-symbol-info-function'."
+  (haskell-doc-sym-doc (haskell-doc-get-current-word)))
 
 
-;@node Mouse interface, Print fctsym, Top level function, top
-;@section Mouse interface for interactive query
+;;@node Mouse interface, Print fctsym, Top level function, top
+;;@section Mouse interface for interactive query
 
-;@cindex haskell-doc-ask-mouse-for-type
+;;@cindex haskell-doc-ask-mouse-for-type
 (defun haskell-doc-ask-mouse-for-type (event)
  "Read the identifier under the mouse and echo its type.
 This uses the same underlying function `haskell-doc-show-type' as the hooked
  (save-excursion
    (select-window (posn-window (event-end event)))
    (goto-char (posn-point (event-end event)))
-   (haskell-doc-show-type )))
- 
+   (haskell-doc-show-type)))
 
-;@node Print fctsym, Movement, Mouse interface, top
-;@section Print fctsym
 
-;@menu
-;* Show type::			
-;* Aux::			
-;* Global fct type::		
-;* Local fct type::		
-;@end menu
+;;@node Print fctsym, Movement, Mouse interface, top
+;;@section Print fctsym
 
-;@node Show type, Aux, Print fctsym, Print fctsym
-;@subsection Show type
+;;@menu
+;;* Show type::
+;;* Aux::
+;;* Global fct type::
+;;* Local fct type::
+;;@end menu
 
-;@cindex haskell-doc-show-type
+;;@node Show type, Aux, Print fctsym, Print fctsym
+;;@subsection Show type
+
+;;@cindex haskell-doc-show-type
 
 ;;;###autoload
-(defun haskell-doc-show-type (&optional symbol)
+(defun haskell-doc-show-type (&optional sym)
   "Show the type of the function near point.
 For the function under point, show the type in the echo area.
 This information is extracted from the `haskell-doc-prelude-types' alist
 of prelude functions and their types, or from the local functions in the
 current buffer."
   (interactive)
-  (let* ((sym (or symbol (haskell-doc-get-current-word))) 
-	; (haskell-doc-current-symbol))); (haskell-doc-fnsym-in-current-sexp)))
-        (printit t)
-        (i-am-prelude nil)
+  (unless sym (setq sym (haskell-doc-get-current-word)))
+  ;; if printed before do not print it again
+  (unless (string= sym (car haskell-doc-last-data))
+    (let ((doc (haskell-doc-sym-doc sym)))
+      (when doc
+        ;; In emacs 19.29 and later, and XEmacs 19.13 and later, all
+        ;; messages are recorded in a log.  Do not put haskell-doc messages
+        ;; in that log since they are legion.
+        (if (eval-when-compile (fboundp 'display-message))
+            ;; XEmacs 19.13 way of preventing log messages.
+            ;;(display-message 'no-log (format <args>))
+            ;; XEmacs 19.15 seems to be a bit different.
+            (display-message 'message (format "%s" doc))
+          (let ((message-log-max nil))
+            (message "%s" doc)))))))
+
+
+(defun haskell-doc-sym-doc (sym)
+  "Show the type of the function near point.
+For the function under point, show the type in the echo area.
+This information is extracted from the `haskell-doc-prelude-types' alist
+of prelude functions and their types, or from the local functions in the
+current buffer."
+  (let ((i-am-prelude nil)
         (i-am-fct nil)
         (type nil)
 	(is-reserved (haskell-doc-is-of sym haskell-doc-reserved-ids))
 	(is-user-defined (haskell-doc-is-of sym haskell-doc-user-defined-ids))
 	(is-prelude  (haskell-doc-is-of sym haskell-doc-prelude-types)))
    (cond
-	  ;; if printed before do not print it again
-          ((string= sym (car haskell-doc-last-data))
-           (setq printit nil)
-           (setq type (cdr haskell-doc-last-data)))
 	  ;; if reserved id (i.e. Haskell keyword
 	  ((and haskell-doc-show-reserved
 	       is-reserved)
            (setcdr haskell-doc-last-data type))
 	  ((and haskell-doc-show-user-defined
 	       is-user-defined)
-	   ; (setq i-am-fct t)
+	   ;; (setq i-am-fct t)
 	   (setq type (cdr is-user-defined))
            (setcdr haskell-doc-last-data type))
           (t
 	       (setcdr haskell-doc-last-data type)))) )
     ;; ToDo: encode i-am-fct info into alist of types
     (and type
-         printit
-	 ; drop `::' if it's not a fct
+	 ;; drop `::' if it's not a fct
 	 (let ( (str (cond ((and i-am-fct (not haskell-doc-chop-off-fctname))
 			    (format "%s :: %s" sym type))
-			   (t 
+			   (t
 			    (format "%s" type)))) )
 	   (if i-am-prelude
-	       (add-text-properties 0 (1- (length str)) '(face bold) str))
-	   (haskell-doc-message "%s" str)))) )
+	       (add-text-properties 0 (length str) '(face bold) str))
+	   str))))
 
 
 ;; ToDo: define your own notion of `near' to find surrounding fct
-;(defun haskell-doc-fnsym-in-current-sexp ()
-;  (let* ((p (point))
-;         (sym (progn
-;		(forward-word -1)
+;;(defun haskell-doc-fnsym-in-current-sexp ()
+;;  (let* ((p (point))
+;;         (sym (progn
+;;		(forward-word -1)
 ;;                (while (and (forward-word -1) ; (haskell-doc-forward-sexp-safe -1)
 ;;                            (> (point) (point-min))))
-;                (cond ((or (= (point) (point-min))
-;                           (memq (or (char-after (point)) 0)
-;                                 '(?\( ?\"))
-;                           ;; If we hit a quotation mark before a paren, we
-;                           ;; are inside a specific string, not a list of
-;                           ;; symbols.
-;                           (eq (or (char-after (1- (point))) 0) ?\"))
-;                       nil)
-;                      (t (condition-case nil
-;                             (read (current-buffer))
-;                           (error nil)))))))
-;    (goto-char p)
-;    (if sym
-;	(format "%s" sym)
-;      sym) ) )
+;;                (cond ((or (= (point) (point-min))
+;;                           (memq (or (char-after (point)) 0)
+;;                                 '(?\( ?\"))
+;;                           ;; If we hit a quotation mark before a paren, we
+;;                           ;; are inside a specific string, not a list of
+;;                           ;; symbols.
+;;                           (eq (or (char-after (1- (point))) 0) ?\"))
+;;                       nil)
+;;                      (t (condition-case nil
+;;                             (read (current-buffer))
+;;                           (error nil)))))))
+;;    (goto-char p)
+;;    (if sym
+;;	(format "%s" sym)
+;;      sym)))
 
 ;;    (and (symbolp sym)
 ;;         sym)))
 
-;@node Aux, Global fct type, Show type, Print fctsym
-;@subsection Aux
+;;@node Aux, Global fct type, Show type, Print fctsym
+;;@subsection Aux
 
 ;; ToDo: handle open brackets to decide if it's a wrapped type
 
-;@cindex haskell-doc-grab-line
+;;@cindex haskell-doc-grab-line
 (defun haskell-doc-grab-line (fct-and-pos)
  "Get the type of an \(FCT POSITION\) pair from the current buffer."
-; (if (null fct-and-pos)
-;     "" ; fn is not a local fct
+ ;; (if (null fct-and-pos)
+ ;;     "" ; fn is not a local fct
   (let ( (str ""))
    (goto-char (cdr fct-and-pos))
    (beginning-of-line)
        (skip-chars-forward " \t")
        (setq str (concat str (haskell-doc-grab))))
      (haskell-doc-string-nub-ws           ; squeeze string
-      (if haskell-doc-chop-off-context    ; no context 
+      (if haskell-doc-chop-off-context    ; no context
 	  (haskell-doc-chop-off-context str)
 	str)))))
-  ; (concat (car fct-and-pos) "::" (haskell-doc-string-nub-ws str))))
+ ;; (concat (car fct-and-pos) "::" (haskell-doc-string-nub-ws str))))
 
-;@cindex haskell-doc-wrapped-type-p
+;;@cindex haskell-doc-wrapped-type-p
 (defun haskell-doc-wrapped-type-p ()
  "Check whether the type under the cursor is wrapped over several lines.
 The cursor must be at the end of a line, which contains the type.
 Currently, only the following is checked:
-If this line ends with a `->' or the next starts with an `->' it is a 
+If this line ends with a `->' or the next starts with an `->' it is a
 multi-line type \(same for `=>'\).
 `--' comments are ignored.
 ToDo: Check for matching parenthesis!. "
  (save-excursion
    (let ( (here (point))
 	  (lim (progn (beginning-of-line) (point)))
-	  ; (foo "")
+	  ;; (foo "")
 	  (res nil)
 	  )
    (goto-char here)
-   (search-backward "--" lim t) ; skip over `--' comment 
+   (search-backward "--" lim t) ; skip over `--' comment
    (skip-chars-backward " \t")
    (if (bolp)                   ; skip empty lines
       (progn
        (end-of-line)
        (setq res (haskell-doc-wrapped-type-p)))
    (forward-char -1)
-   ; (setq foo (concat foo (char-to-string (preceding-char)) (char-to-string (following-char))))
+   ;; (setq foo (concat foo (char-to-string (preceding-char)) (char-to-string (following-char))))
    (if (or (and (or (char-equal (preceding-char) ?-) (char-equal (preceding-char) ?=))
 		(char-equal (following-char) ?>)) ; (or -!> =!>
 	   (char-equal (following-char) ?,))      ;     !,)
        (setq res t)
      (forward-line)
-     (let ( (here (point))
-	    (lim (progn (end-of-line) (point)))
-	    )
+     (let ((here (point)))
        (goto-char here)
        (skip-chars-forward " \t")
        (if (looking-at "--")  ; it is a comment line
 	     (end-of-line)
 	     (setq res (haskell-doc-wrapped-type-p)))
 	 (forward-char 1)
-	 ; (setq foo (concat foo (char-to-string (preceding-char)) (char-to-string (following-char))))
-	 ; (message "|%s|" foo)
+	 ;; (setq foo (concat foo (char-to-string (preceding-char)) (char-to-string (following-char))))
+	 ;; (message "|%s|" foo)
 	 (if (and (or (char-equal (preceding-char) ?-) (char-equal (preceding-char) ?=))
 		  (char-equal (following-char) ?>)) ; -!> or =!>
 	     (setq res t))))))
    res)))
 
-;@cindex haskell-doc-grab
+;;@cindex haskell-doc-grab
 (defun haskell-doc-grab ()
  "Return the text from point to the end of the line, chopping off comments.
 Leaves point at end of line."
        str
      (substring str 0 i))))
 
-;@cindex haskell-doc-string-nub-ws
+;;@cindex haskell-doc-string-nub-ws
 (defun haskell-doc-string-nub-ws (str)
   "Replace all sequences of whitespaces in STR by just one whitespace.
 ToDo: Also eliminate leading and trainling whitespace."
  (let (
        (res str)
        (i 0)
-       ) 
+       )
   (setq i (string-match "\\(\\s-+\\)" res i))
   (while (not (null i))
     (setq res (replace-match " " t t res))
     (setq i (string-match "\\(\\s-+\\)" res (1+ i))) )
   res) )
 
-; ToDo: make this more efficient!!
-;(defun haskell-doc-string-nub-ws (str)
-;  "Replace all sequences of whitespaces in STR by just one whitespace."
-;  (let ( (res "") 
-;	 (l (length str))
-;	 (i 0)
-;	 (j 0)
-;	 (in-ws nil))
-;   (while (< i l)
-;     (let* ( (c (string-to-char (substring str i (1+ i))))
-;	    (is-ws (eq (char-syntax c) ? )) )
-;       (if (not (and in-ws is-ws))
-;	     (setq res (concat res (char-to-string c))))
-;       (setq in-ws is-ws)
-;       (setq i (1+ i))))
-;   res))
+;; ToDo: make this more efficient!!
+;;(defun haskell-doc-string-nub-ws (str)
+;;  "Replace all sequences of whitespaces in STR by just one whitespace."
+;;  (let ( (res "")
+;;	 (l (length str))
+;;	 (i 0)
+;;	 (j 0)
+;;	 (in-ws nil))
+;;   (while (< i l)
+;;     (let* ( (c (string-to-char (substring str i (1+ i))))
+;;	    (is-ws (eq (char-syntax c) ? )) )
+;;       (if (not (and in-ws is-ws))
+;;	     (setq res (concat res (char-to-string c))))
+;;       (setq in-ws is-ws)
+;;       (setq i (1+ i))))
+;;   res))
 
-;@cindex haskell-doc-chop-off-context
+;;@cindex haskell-doc-chop-off-context
 (defun haskell-doc-chop-off-context (str)
  "Eliminate the contex in a type represented by the string STR."
- (let ((i (string-match "=>" str)) ) 
+ (let ((i (string-match "=>" str)) )
    (if (null i)
        str
      (substring str (+ i 2)))))
 
-;@cindex haskell-doc-get-imenu-info
+;;@cindex haskell-doc-get-imenu-info
 (defun haskell-doc-get-imenu-info (obj kind)
   "Returns a string describing OBJ of KIND \(Variables, Types, Data\)."
   (cond ((or (eq major-mode 'haskell-hugs-mode)
              ;; GEM: Haskell Mode does not work with Haskell Doc
              ;;      under XEmacs 20.x
              (and (eq major-mode 'haskell-mode)
-                  (not (and haskell-doc-xemacs-p
+                  (not (and (featurep 'xemacs)
                             (string-match "^20" emacs-version)))))
-	 (let* ( (imenu-info-alist (cdr (assoc kind imenu--index-alist)))
-		 ; (names (mapcar (lambda (x) (car x)) imenu-info-alist))
-		 (x (assoc obj imenu-info-alist))
-	       )
+	 (let* ((imenu-info-alist (cdr (assoc kind imenu--index-alist)))
+                ;; (names (mapcar 'car imenu-info-alist))
+                (x (assoc obj imenu-info-alist)))
 	     (if x
 		 (haskell-doc-grab-line x)
-	       nil)) )
+	       nil)))
 	  (t
-	   ; (error "Cannot get local functions in %s mode, sorry" major-mode))) )
+           ;; (error "Cannot get local functions in %s mode, sorry" major-mode))) )
 	   nil)))
 
-;@node Global fct type, Local fct type, Aux, Print fctsym
-;@subsection Global fct type
+;;@node Global fct type, Local fct type, Aux, Print fctsym
+;;@subsection Global fct type
 
 ;; ToDo:
 ;;  - modular way of defining a mapping of module name to file
 ;;  - use a path to search for file (not just current directory)