Tuesday, April 14, 2009

Ocaml documentation in emacs

Zach made a post for how to do this in Vim, so I was curious how to do it in emacs. First define this in your custom.el or whatever



(defun ocaml-lookup-module ()
(interactive) ;; to run from keybinding
(let ((sym (thing-at-point 'symbol)))
(if sym
(shell-command
(concat "firefox http://caml.inria.fr/pub/docs/manual-ocaml/libref/"
(concat sym ".html")))
)))


then add the binding w/ something like this:


(add-hook 'tuareg-mode-hook
(lambda ()
(define-key tuareg-mode-map (kbd "M-?") 'ocaml-lookup-module)))


To use it from tuareg (or ocaml) mode, put your cursor over the name of an Ocaml standard library module (e.g. "Set" if you have the text "Set.union ..." in your source) and hit "M-?"

No comments: