utop-ocaml-preprocessor - allow loading also pre-procesor from local file variables

Ignore-this: 50e32972f422612675d47fd9ce33fc43

darcs-hash:20120731234941-33bd9-16a892de7fff014771091a9a138380d665bdadd9
This commit is contained in:
wojciech.meyer 2012-08-01 01:49:41 +02:00
parent 5a47685bfb
commit 272f6f5c29
1 changed files with 23 additions and 3 deletions

View File

@ -193,6 +193,10 @@ to add the newline character if it is not accepted).")
"List of packages to load when visiting OCaml buffer.
Useful as file variable.")
(defvar utop-ocaml-preprocessor nil
"Name of preprocesor. Currently supported camlp4o, camlp4r.
Useful as file variable.")
;; +-----------------------------------------------------------------+
;; | Compability |
;; +-----------------------------------------------------------------+
@ -826,11 +830,19 @@ To automatically do that just add these lines to your .emacs:
(utop-choose-defun "interrupt-caml" () (interactive) (utop-interrupt))
(utop-choose-defun "kill-caml" () (interactive) (utop-kill))
(utop-choose-defun "run-caml" () (interactive) (utop))
;; Redefine this variable so menu will work
(set (utop-choose "interactive-buffer-name") utop-buffer-name)
;; Package list for this file
(make-local-variable 'utop-package-list)
(make-local-variable 'utop-camlp)
(add-hook 'hack-local-variables-hook 'utop-query-load-package-list)
;; Preprocessor to use
(make-local-variable 'utop-ocaml-preprocessor)
;; Load local file variables
(add-hook 'hack-local-variables-hook 'utop-hack-local-variables)
nil)
;; +-----------------------------------------------------------------+
@ -984,7 +996,15 @@ defaults to 0."
"You've defined utop-package-list variable, but uTop toplevel is not running, would you like me to start the toplevel?"))
(with-current-buffer (utop))
(mapc 'utop-load-package utop-package-list)
(message "OCaml packages loaded by file local variables")))
(message "uTop: OCaml packages loaded by file local variables")))
(defun utop-hack-local-variables ()
"Perform actions defined by local variables"
(when utop-ocaml-preprocessor
(with-current-buffer (utop))
(utop-eval-string (format "#%s" utop-ocaml-preprocessor)))
(message (format "uTop: %s preprocessor loaded" utop-ocaml-preprocessor))
(utop-query-load-package-list))
;; +-----------------------------------------------------------------+
;; | Menu |