emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/tuareg eb3d8bb411 2/2: Apply review suggestions by @monnie


From: ELPA Syncer
Subject: [nongnu] elpa/tuareg eb3d8bb411 2/2: Apply review suggestions by @monnier
Date: Tue, 18 Jul 2023 16:03:11 -0400 (EDT)

branch: elpa/tuareg
commit eb3d8bb411d1bdbadc6c823c9b4525dc287488d2
Author: Erik Martin-Dorel <erik@martin-dorel.org>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>

    Apply review suggestions by @monnier
    
    (tuareg-opam-update-env): call #'opam-switch-set-switch if (featurep 
'opam-switch-mode)
---
 tuareg-opam.el | 36 ++++++++++++++++++++++--------------
 tuareg.el      | 15 ++++++---------
 2 files changed, 28 insertions(+), 23 deletions(-)

diff --git a/tuareg-opam.el b/tuareg-opam.el
index b3bd0395b2..2ad3e80a9a 100644
--- a/tuareg-opam.el
+++ b/tuareg-opam.el
@@ -351,8 +351,8 @@ opam switch at the time the command is run (provided opam is
 found).  You may also use `tuareg-opam-update-env', or the menus
 from the ELPA package `opam-switch-mode', to set the
 environment for another compiler from within emacs (without
-changing the opam switch).  Beware that setting it to t causes
-problems if you compile under tramp."
+affecting the OPAM switches outside of this Emacs session).
+Beware that setting it to t causes problems if you compile under tramp."
   :group 'tuareg :type 'boolean)
 
 (defun tuareg--shell-command-to-string (command)
@@ -385,23 +385,31 @@ error message as a string)."
 (defun tuareg-opam-update-env (switch)
   "Update the environment to follow current OPAM switch configuration.
 
-You may also be interested in the ELPA package `opam-switch-mode' that
-provides a similar feature, along with a menu-bar and a mode-bar menu
-`\"OPSW\"'; see https://github.com/ProofGeneral/opam-switch-mode.";
+Delegate the task to `opam-switch-set-switch' if the minor mode
+`opam-switch-mode' (https://github.com/ProofGeneral/opam-switch-mode)
+is installed. This ELPA package also provides a menu-bar and a
+mode-bar menu `\"OPSW\"'."
+  (declare (obsolete opam-switch-set-switch "2023-07"))
   (interactive
    (let* ((compl (tuareg-opam-installed-compilers))
           (current (tuareg-opam-current-compiler))
           (default (if current current "current"))
           (prompt (format "opam switch (default: %s): " default)))
-     (list (completing-read prompt compl))))
-  (let* ((switch (if (string= switch "") nil switch))
-         (env (tuareg-opam-config-env switch)))
-    (if env
-        (dolist (v env)
-          (setenv (car v) (cadr v))
-          (when (string= (car v) "PATH")
-            (setq exec-path (split-string (cadr v) path-separator))))
-      (message "Switch %s does not exist (or opam not found)" switch))))
+     (if (fboundp 'opam-switch-set-switch)
+         '(use-opam-switch-interactively)
+       (list (completing-read prompt compl)))))
+  (if (fboundp 'opam-switch-set-switch)
+      (if (eq switch 'use-opam-switch-interactively)
+          (call-interactively #'opam-switch-set-switch)
+        (opam-switch-set-switch switch))
+    (let* ((switch (if (string= switch "") nil switch))
+           (env (tuareg-opam-config-env switch)))
+      (if env
+          (dolist (v env)
+            (setenv (car v) (cadr v))
+            (when (string= (car v) "PATH")
+              (setq exec-path (split-string (cadr v) path-separator))))
+        (message "Switch %s does not exist (or opam not found)" switch)))))
 
 ;; OPAM compilation
 (defun tuareg--compile-opam (&rest _)
diff --git a/tuareg.el b/tuareg.el
index d9461e76a0..c70470c350 100644
--- a/tuareg.el
+++ b/tuareg.el
@@ -3925,12 +3925,10 @@ If the region is active, evaluate all phrases 
intersecting the region."
       (comint-kill-subjob))))
 
 (defcustom tuareg-kill-ocaml-on-opam-switch t
-  "If t, kill the OCaml toplevel before the opam switch changes.
-If the user changes the opam switch using `opam-switch-set-switch'
-or an `\"OPSW\"' menu from `opam-switch-mode', this option asks to
-kill the OCaml toplevel process, so that the next eval command
-starts a new process, typically with a different OCaml version
-from a different opam switch.
+    "If t, kill Tuareg subprocesses when the OPAM switch changes.
+If the user changes the OPAM switch using `opam-switch-mode',
+this option asks to kill the subprocesses that are using the old
+switch.
 
 See https://github.com/ProofGeneral/opam-switch-mode
 
@@ -3938,9 +3936,8 @@ Note: `opam-switch-mode' triggers automatic changes for 
`exec-path'
 and `process-environment', which are useful to find the `\"ocaml\"'
 binary and that of its subprocesses, in the ambient opam switch.
 
-`opam-switch-mode' 1.6+ is compatible with `tuareg-mode' whatever
-is the value of `tuareg-opam-insinuate' (albeit the default value
-nil is recommended as it omits the `\"opam exec --\"' wrapper)."
+`opam-switch-mode' is compatible with `tuareg-mode' whatever is
+the value of `tuareg-opam-insinuate'."
   :type 'boolean)
 
 (defun tuareg--kill-ocaml-on-opam-switch ()



reply via email to

[Prev in Thread] Current Thread [Next in Thread]