From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id C34927EE25 for ; Tue, 4 Jun 2013 16:55:27 +0200 (CEST) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of lpw25@cam.ac.uk) identity=pra; client-ip=131.111.8.133; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="lpw25@cam.ac.uk"; x-sender="lpw25@cam.ac.uk"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of lpw25@cam.ac.uk) identity=mailfrom; client-ip=131.111.8.133; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="lpw25@cam.ac.uk"; x-sender="lpw25@cam.ac.uk"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@ppsw-33.csi.cam.ac.uk) identity=helo; client-ip=131.111.8.133; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="lpw25@cam.ac.uk"; x-sender="postmaster@ppsw-33.csi.cam.ac.uk"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AskAAIz+rVGDbwiFlGdsb2JhbABahnW7XHoWDgEBAQEHDQkJFAUjgiMBAQEDASNWBQsLGAICBSECAg8BBA08ExuHYAMJBqtJiR8NS4gXgSaLI4IoMweCR4EUA5VYjgSIMw X-IPAS-Result: AskAAIz+rVGDbwiFlGdsb2JhbABahnW7XHoWDgEBAQEHDQkJFAUjgiMBAQEDASNWBQsLGAICBSECAg8BBA08ExuHYAMJBqtJiR8NS4gXgSaLI4IoMweCR4EUA5VYjgSIMw X-IronPort-AV: E=Sophos;i="4.87,800,1363129200"; d="scan'208";a="16734177" Received: from ppsw-33.csi.cam.ac.uk ([131.111.8.133]) by mail3-smtp-sop.national.inria.fr with ESMTP; 04 Jun 2013 16:55:27 +0200 X-Cam-AntiVirus: no malware found X-Cam-ScannerInfo: http://www.cam.ac.uk/cs/email/scanner/ Received: from kingston.cl.cam.ac.uk ([128.232.64.15]:49998) by ppsw-33.csi.cam.ac.uk (smtp.hermes.cam.ac.uk [131.111.8.157]:587) with esmtpsa (PLAIN:lpw25) (TLSv1.2:DHE-RSA-AES128-SHA:128) id 1Ujsdy-0001tU-hs (Exim 4.80_167-5a66dd3) (return-path ); Tue, 04 Jun 2013 15:55:26 +0100 From: Leo White To: Wojciech Meyer Cc: Christophe TROESTLER , , References: <87li6z8x0m.fsf@ieee.org> <20130528.102112.1182989008075506917.Christophe.Troestler@umons.ac.be> Date: Tue, 04 Jun 2013 15:55:26 +0100 In-Reply-To: (Wojciech Meyer's message of "Wed, 29 May 2013 22:39:38 +0100") Message-ID: <878v2qj57l.fsf@kingston.cl.cam.ac.uk> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Caml-list] Setting up OPAM in emacs My personal solution for Tuareg mode is to put: ;; Use OPAM's ocaml (setq tuareg-interactive-program "opam config exec ocaml") in my .emacs. Regards, Leo Wojciech Meyer writes: > Christophe's function hook is probably much better and elegant solution, > but this works for me: > >>> > (defun dm-opam-switch-root (ocaml-version opam-root) > (interactive "sOCaml version: \nsOPAM root: ") > (let* ((path (if (string-match "\\.opam" (car exec-path)) (cdr exec-pat= h) exec-path)) > (entry > (replace-regexp-in-string > "\n" "" > (shell-command-to-string > (format "opam switch --root %s %s > /dev/null && opam config = env | sed -n 's/^PATH=3D\\([^:]\\+\\):.*$/\\1/p'" opam-root ocaml-version))= )) > (env-path (replace-regexp-in-string "\n" "" (shell-command-to-st= ring (format "opam config env --root %s | sed -n 's/^PATH=3D\\(.*\\)/\\1/p'= " opam-root))))) > (setq exec-path (cons entry path)) > (setenv "PATH" env-path))) > > (defun dm-opam-switch (ocaml-version) > (interactive "sOCaml version: ") > (dm-opam-switch-root ocaml-version "~/.opam")) > << > > I wouldn't say myself it's a perfect script, but it works. Note that I > use a lot of shell trickery instead of Emacs buffers, which is probably > not a good idea. > > You just say M-x dm-opam-switch, and indicate which version you would > like. > > Best, > Wojciech > > Christophe TROESTLER writes: > >> On Tue, 28 May 2013 09:59:53 +0400, Ivan Gotovchits wrote: >>> >>> 2. Use =C2=ABeval `opam env config`=C2=BB in the begining of a compile-= command. >>> This works fine when you switch compiler, but other commands, such as >>> =C2=ABC-c C-s=C2=BB doesn't use new environment. >> >> I use this for the compilation: >> >> ;; OPAM compilation =E2=80=94 one must update to the current compiler >> ;; before launching the compilation. >> (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-char (point-min)) >> (while (re-search-forward "; *export.*$" nil t) >> (replace-match "" nil nil)) >> (split-string (buffer-substring 1 (point-max))) >> ))) >> >> For the toplevel, I am afraid one needs to restart it. I guess a >> similar trick is possible to automatically select the right one. >> >> Hope it helps, >> C.