better tuareg integration

Ignore-this: 4ba7fb3a818232c1423c9d7f1a65f318

darcs-hash:20120203094158-c41ad-f9d191e4ead0c4e8f7c7156edf1d92b3c381ac8e
This commit is contained in:
Jeremie Dimino 2012-02-03 10:41:58 +01:00
parent e52fb6987a
commit 21ebe44ff0
3 changed files with 25 additions and 25 deletions

14
README
View File

@ -66,18 +66,8 @@ url: https://forge.ocamlcore.org/projects/utop/
You can replace the default toplevel used by the tuareg mode by
utop, for that add the following lines to your ~/.emacs file:
(autoload 'utop-eval-region "utop" "Toplevel for OCaml" t)
(autoload 'utop-eval-phrase "utop" "Toplevel for OCaml" t)
(autoload 'utop-eval-buffer "utop" "Toplevel for OCaml" t)
(defun tuareg-utop-hook ()
(local-set-key "\M-\C-x" 'utop-eval-phrase)
(local-set-key "\C-x\C-e" 'utop-eval-phrase)
(local-set-key "\C-c\C-e" 'utop-eval-phrase)
(local-set-key "\C-c\C-r" 'utop-eval-region)
(local-set-key "\C-c\C-b" 'utop-eval-buffer))
(add-hook 'tuareg-mode-hook 'tuareg-utop-hook)
(autoload 'utop-tuareg-setup "utop" "Toplevel for OCaml" t)
(add-hook 'tuareg-mode-hook 'utop-tuareg-setup)
* Development:

View File

@ -80,18 +80,8 @@ lines to your
.I ~/.emacs
file:
(autoload 'utop-eval-region "utop" "Toplevel for OCaml" t)
(autoload 'utop-eval-phrase "utop" "Toplevel for OCaml" t)
(autoload 'utop-eval-buffer "utop" "Toplevel for OCaml" t)
(defun tuareg-utop-hook ()
(local-set-key "\\M-\\C-x" 'utop-eval-phrase)
(local-set-key "\\C-x\\C-e" 'utop-eval-phrase)
(local-set-key "\\C-c\\C-e" 'utop-eval-phrase)
(local-set-key "\\C-c\\C-r" 'utop-eval-region)
(local-set-key "\\C-c\\C-b" 'utop-eval-buffer))
(add-hook 'tuareg-mode-hook 'tuareg-utop-hook)
(autoload 'utop-tuareg-setup "utop" "Toplevel for OCaml" t)
(add-hook 'tuareg-mode-hook 'utop-tuareg-setup)
.SH OPTIONS
Same as

View File

@ -445,7 +445,7 @@ sub-process."
"Eval the current region in utop."
(interactive "r")
(utop-prepare-for-eval)
(utop-eval (start end)))
(utop-eval start end))
(defun utop-eval-phrase ()
"Eval the surrounding Caml phrase (or block) in utop."
@ -465,6 +465,26 @@ sub-process."
(utop-prepare-for-eval)
(utop-eval (point-min) (point-max)))
(defun utop-tuareg-setup ()
"Override tuareg interactive functions by utop ones.
You can call this function after loading the tuareg mode to let
it use utop instead of its builtin support for interactive
toplevel.
To automatically do that just add these lines to your .emacs:
(autoload 'utop-tuareg-setup \"utop\" \"Toplevel for OCaml\" t)
(add-hook 'tuareg-mode-hook 'utop-tuareg-setup)"
(interactive)
(defun tuareg-eval-phrase () (interactive) (utop-eval-phrase))
(defun tuareg-eval-region (start end) (interactive "r") (utop-eval-region start end))
(defun tuareg-eval-buffer () (interactive) (utop-eval-buffer))
(defun tuareg-interrupt-caml () (interactive) (utop-interrupt))
(defun tuareg-kill-caml () (interactive) (utop-kill))
(defun tuareg-run-caml () (interactive) (utop))
nil)
;; +-----------------------------------------------------------------+
;; | Edition functions |
;; +-----------------------------------------------------------------+