Permalink
Browse files

emacs: Documentation.

  • Loading branch information...
asmanur committed Mar 17, 2013
1 parent 70740f8 commit 05c765c6b9f7095d0e115cb0880e7a4097b949e6
Showing with 55 additions and 13 deletions.
  1. +47 −11 README.md
  2. +8 −2 emacs/merlin.el
View
@@ -127,37 +127,69 @@ Emacs interface
merlin comes with an emacs interface (file: emacs/merlin.el) that implements a
minor-mode that is supposed to be used on top of tuareg-mode.
-To install it, just M-x load-file /wherever/merlin.el. To use it, you will need
+To get it working you only to load the file `emacs/merlin.el' of the distribution.
+
+If you installed through opam, a good thing to do is:
+
+
+ (add-to-list 'load-path ".opam/4.00.1/share/emacs/site-lisp/")
+ (require 'merlin)
+
+
+To use it, you will need
- json.el (available by package.el)
- auto-complete-mode (morally optional, available by package.el and the MELPA repository)
-Once it is done, to enable merlin in a buffer, just type M-x merlin-mode. It
-will spawn an instance of ocamlmerlin in a separate buffer.
+Once it is done, to enable merlin in a buffer, just type M-x merlin-mode. If you want merlin to be started on every ML buffer issue:
+
+ (add-hook 'tuareg-mode-hook 'merlin-mode)
+
+
+Features
+--------
merlin implements a locked zone like proofgeneral to know what merlin knows of
the buffer. To advance or retract the locked zone to the point, use C-c C-RET.
-Note that retraction can go before the point in case the point is not at the
-end of the last definition.
+Note that retraction can go before the point in case the point is not at the end
+of the last definition. Lock zone is by default shown using a marker in the
+margin of the last line of it. The behaviour is controlled by the variable
+`merlin-display-lock-zone'.
Main keybindings:
- C-c l allows you to load a findlib package inside merlin. For a project you
should use a .merlin file
-- C-c C-t will show you the type of the expression under point. Further calls
- will show the types of bigger expressions surrounding the point. C-u C-c C-t
- will show type of smaller expression (only valid if you went up at least once)
+- C-c C-t will show you the type of the expression under point. The behaviour of
+ this is quite complex. It will:
+
+ - try to find the node of the typed AST the current point is in, and returns
+ this type. Further call to C-c C-t allow to go up (or down with a prefix
+ argument) in the AST
+
+ - try to type the ident under point within the local environment
+
+ - try to type the ident under point within the local environment.
+
+ Moreover, C-u C-c C-t is used to type the region (if there is no selected AST
+ node)
+
+- C-c C-x goes to the next error
+
+- C-c C-u refreshes merlin's cache (when you recompiled other files, might be
+ handy)
- C-c C-r retracts the whole buffer (useful when merlin seems confused)
-- C-c d will print the definition of the type of the expression underpoint if any
+- C-c d will print the definition of the type of the expression underpoint if
+ any. If the type is compliated (eg. 'a -> 'a option) it will print the definition of the codomain
- C-c TAB will synchronize and completes expression under point.
-Moreover, you have autocompletion with merlin (and for now only with merlin),
+Moreover, you have autocompletion with merlin,
and whenever you stay idle for one second you get the type of the ident under
-the point (modules are not displayed), pretty much like haskell-mode.
+the point (modules are not displayed).
Auto-completion
---------------
@@ -172,6 +204,10 @@ If you find the types when completing noisy you can use
in your .emacs
+Idle
+----
+By setting the variable merlin-idle-delay you can have the type of the expression under point displayed after doing nothing. The default timer is three seconds.
+
Merlin project
==============
View
@@ -423,9 +423,10 @@ It proceeds by telling (with the end mode) each line until it returns true or un
"2 sec")
(setq merlin-idle-point (point))
(if merlin-pending-errors
- (message "%s (%d more errors)"
+ (message "%s (%d more errors, use %s to go to the next)"
(cdr (assoc 'message err))
(length merlin-pending-errors)
+ (substitute-command-keys "\\[merlin-next-error]")
)
(message "%s" (cdr (assoc 'message err)))))
(message "no more errors")))
@@ -456,10 +457,15 @@ It proceeds by telling (with the end mode) each line until it returns true or un
(merlin-put-margin-overlay overlay "?" compilation-warning-face)
(merlin-put-margin-overlay overlay "!" compilation-error-face))
overlay)) errors))
- (message "(pending errors, use C-c C-x to jump)"))
+ (message "(pending errors, use %s to jump)"
+ (substitute-command-keys "\\[merlin-next-error]")))
(defun merlin-check-for-errors (view-errors-p)
"Check for errors. It returns `t' if there were not any or nil if there were.
+
+
+
+
Moreover if `view-errors-p' is not nil, it will display them in the margin."
(let ((output (merlin-send-command "errors" nil)))
(if (> (length (elt output 1)) 0)

0 comments on commit 05c765c

Please sign in to comment.