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 BABA07EE25 for ; Sat, 15 Jun 2013 14:08:33 +0200 (CEST) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of gabriel.scherer@gmail.com) identity=pra; client-ip=209.85.214.52; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="gabriel.scherer@gmail.com"; x-sender="gabriel.scherer@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of gabriel.scherer@gmail.com designates 209.85.214.52 as permitted sender) identity=mailfrom; client-ip=209.85.214.52; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="gabriel.scherer@gmail.com"; x-sender="gabriel.scherer@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-bk0-f52.google.com) identity=helo; client-ip=209.85.214.52; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="gabriel.scherer@gmail.com"; x-sender="postmaster@mail-bk0-f52.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AqUBABdYvFHRVdY0jmdsb2JhbABagzpJrCOSIn0IFg4BAQEBBw0JCRIGJIIjAQEFQAEbEgsBAwwGBQsNDSEhAQERAQUBChIGExIJh2ABAw8MnCaMS4J/hCAKGScDCliHdAEFDIxYgjIzB4NgA5VagWeBKYp2gz8WKYQ3Og X-IPAS-Result: AqUBABdYvFHRVdY0jmdsb2JhbABagzpJrCOSIn0IFg4BAQEBBw0JCRIGJIIjAQEFQAEbEgsBAwwGBQsNDSEhAQERAQUBChIGExIJh2ABAw8MnCaMS4J/hCAKGScDCliHdAEFDIxYgjIzB4NgA5VagWeBKYp2gz8WKYQ3Og X-IronPort-AV: E=Sophos;i="4.87,871,1363129200"; d="scan'208";a="17904078" Received: from mail-bk0-f52.google.com ([209.85.214.52]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 15 Jun 2013 14:08:32 +0200 Received: by mail-bk0-f52.google.com with SMTP id d7so597186bkh.39 for ; Sat, 15 Jun 2013 05:08:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; bh=8XWJ8QAUrLKcbAaqx4btdBHVz25Xfnsbt70vX4DHMcQ=; b=0lfLzoiv5/penlLZNqkCv5l4g7cLqRzBRrkeGWVRodsRsG9yb/z+lcbmNA/CFI/bXg LP82uhy+jjVsEiQfKw+V15ql2Z3izgcvniuuIWLOHWWFTKDWAE57yJWnwl7oONFBRZwM JuZRpvhCFtSHiX77AjMaSpgaNkZste6U2lWrrOgBy4THkerP/kB6h2CeMGrVxvP3Msd9 LDUZ4JkSfGB4CB7r++N8aDg5rVV1jF2hAPKQOo5PngfF6DkxkbltTfUdtLG4NdNoeHDk j/2DGtU8tx6hi8equ8oZz+jY7OUx1P/opM++TAjCnghghFfO4iyhOu9MHaa/noB+O5eY YTlg== X-Received: by 10.204.227.196 with SMTP id jb4mr274337bkb.96.1371298112357; Sat, 15 Jun 2013 05:08:32 -0700 (PDT) MIME-Version: 1.0 Received: by 10.205.16.10 with HTTP; Sat, 15 Jun 2013 05:07:51 -0700 (PDT) In-Reply-To: <878v2qj57l.fsf@kingston.cl.cam.ac.uk> References: <87li6z8x0m.fsf@ieee.org> <20130528.102112.1182989008075506917.Christophe.Troestler@umons.ac.be> <878v2qj57l.fsf@kingston.cl.cam.ac.uk> From: Gabriel Scherer Date: Sat, 15 Jun 2013 14:07:51 +0200 Message-ID: To: caml users Cc: Wojciech Meyer , Christophe TROESTLER , ivg@ieee.org, Leo White , opam-devel@lists.ocaml.org Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Subject: Re: [Caml-list] Setting up OPAM in emacs I don't (want to) understand the details of why opam switches don't work well with Emacs right now, or of any of the proposed solutions. Is there a solution integrated in OPAM by now? If not, is there a consensus on what simple users like me should use to solve the problem? Could you (the thread participants) decide on something, and send that to the OPAM upstream, so that future versions solve this issue? (The immediate problem I observe is that compile-command does not use the OCaml versions I would expect it to, in general defaulting to my system OCaml -- that may depend on the way Emacs is launched. More sophisticated things such as being able to call "opam switch" from inside Emacs are probably secondary needs, and I would be fine with a basic integration not supporting that, and letting people hone their emacs-lisp skills for that.) On Tue, Jun 4, 2013 at 4:55 PM, Leo White wrote: > 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-pa= th) 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-s= tring (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 =ABeval `opam env config`=BB in the begining of a compile-comma= nd. >>>> This works fine when you switch compiler, but other commands, such = as >>>> =ABC-c C-s=BB doesn't use new environment. >>> >>> I use this for the compilation: >>> >>> ;; OPAM compilation =97 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. > > -- > Caml-list mailing list. Subscription management and archives: > https://sympa.inria.fr/sympa/arc/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs