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 mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 944B77EE51 for ; Wed, 29 May 2013 23:39:26 +0200 (CEST) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of wojciech.meyer@gmail.com) identity=pra; client-ip=74.125.82.45; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="wojciech.meyer@gmail.com"; x-sender="wojciech.meyer@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of wojciech.meyer@gmail.com designates 74.125.82.45 as permitted sender) identity=mailfrom; client-ip=74.125.82.45; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="wojciech.meyer@gmail.com"; x-sender="wojciech.meyer@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-wg0-f45.google.com) identity=helo; client-ip=74.125.82.45; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="wojciech.meyer@gmail.com"; x-sender="postmaster@mail-wg0-f45.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AlsBAKx0plFKfVItjWdsb2JhbABaDoZmvkmBChYOAQEBAQcLCwkSBiSCIwEBBAEjHQEbHQEDAQsGBQsNAgIFIQICDwEEDxEBBQEiExuHXwEDCQYEm3mLcE+CfYRuChknDViIIgEFDIEajTozB4JDgRQDlzuPWz+Ddz8 X-IPAS-Result: AlsBAKx0plFKfVItjWdsb2JhbABaDoZmvkmBChYOAQEBAQcLCwkSBiSCIwEBBAEjHQEbHQEDAQsGBQsNAgIFIQICDwEEDxEBBQEiExuHXwEDCQYEm3mLcE+CfYRuChknDViIIgEFDIEajTozB4JDgRQDlzuPWz+Ddz8 X-IronPort-AV: E=Sophos;i="4.87,766,1363129200"; d="scan'208";a="19527984" Received: from mail-wg0-f45.google.com ([74.125.82.45]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 29 May 2013 23:39:26 +0200 Received: by mail-wg0-f45.google.com with SMTP id n12so6945456wgh.12 for ; Wed, 29 May 2013 14:39:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type:content-transfer-encoding; bh=sD0UKFESEml4KvjI/A3kfdw6SreRbazdqIcuRAQquiM=; b=qvT1YCCYtx7MYRtzYOEy/EFhlE5vzc9KRlUak8ocjA5t7UjSdOYbB9jTEBoB+56My1 cJQNeEPllJeUxwT76nWW9gOOcRBKFfLQYuz6kZUND+x8ueLNFAwWqGQbmk4d6YrAIe9Z yksX5KbksgclN03rXqomanhkzPQKnOEU+/bxXXWaga/uc8A/z8Tpp7IxAI2m7whNZCfS 6BuWXGnk5mgLTuYK3oOH+0kGt9rbY2lnd9Cox5Gc3gp3KoBA0q1cnCrph673jd1YzgWK rkjlXJcl5y1+Q6fsyYrknaSCKeHEsVfkQJgjVxqquk9oL7Zc7KLbpcCB8Q7cuBZLx3TU j0TQ== X-Received: by 10.180.205.178 with SMTP id lh18mr2289955wic.47.1369863565810; Wed, 29 May 2013 14:39:25 -0700 (PDT) Received: from spec-desktop.danmey.org (cpc2-cmbg12-0-0-cust796.5-4.cable.virginmedia.com. [86.9.203.29]) by mx.google.com with ESMTPSA id k10sm33987797wia.4.2013.05.29.14.39.24 for (version=TLSv1.1 cipher=RC4-SHA bits=128/128); Wed, 29 May 2013 14:39:24 -0700 (PDT) From: Wojciech Meyer To: Christophe TROESTLER Cc: , References: <87li6z8x0m.fsf@ieee.org> <20130528.102112.1182989008075506917.Christophe.Troestler@umons.ac.be> Date: Wed, 29 May 2013 22:39:38 +0100 In-Reply-To: <20130528.102112.1182989008075506917.Christophe.Troestler@umons.ac.be> (Christophe TROESTLER's message of "Tue, 28 May 2013 10:21:12 +0200") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (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 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-path)= exec-path)) (entry (replace-regexp-in-string "\n" "" (shell-command-to-string (format "opam switch --root %s %s > /dev/null && opam config en= v | sed -n 's/^PATH=3D\\([^:]\\+\\):.*$/\\1/p'" opam-root ocaml-version)))) (env-path (replace-regexp-in-string "\n" "" (shell-command-to-stri= ng (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-c= ommand. >> 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.