[ocaml-platform] "opam config env" and emacs

Christophe TROESTLER Christophe.Troestler at umons.ac.be
Sat Apr 6 19:24:25 BST 2013


Hi,

Maybe some ~/.opam/opam.el package would indeed be useful.  On a
related note, I have the following added to 'tuareg-mode-hook so that
the compilation (C-cC-c) uses the currently selected OPAM compiler.

    (defadvice compile (before compile-opam activate)
      "Run opam to update environment variables"
      (set (make-local-variable 'compilation-environment)
	   (with-temp-buffer
	     (ignore-errors (call-process "opam" nil t nil "config" "-env"))
	     (goto-line 1)
	     (while (re-search-forward "; *export.*$" nil t)
	       (replace-match "" nil nil))
	     (split-string (buffer-substring 1 (point-max)))
	     )))

Best,
C.

On Sat, 6 Apr 2013 14:12:39 -0400, Yaron Minsky wrote:
> 
> Does anyone know a good way of setting up emacs to point to the
> appropriate site-lisp directory in OPAM?  Right now, I have a stanza
> like this in my .emacs:
> 
> (add-to-list 'load-path
>              (expand-file-name
> "~/.opam/4.01.0dev+trunk/share/emacs/site-lisp/"))
> 
> But this is of course not at all sensitive to opam switch.  Jeremie
> has some auto-detection code here:
> 
>    https://github.com/diml/utop/issues/4
> 
> Should we integrate this into OPAM somehow so people don't have to dig
> this out and cut and paste it in?


More information about the Platform mailing list