branch: elpa/opam-switch-mode
commit 0a0dfa84e1e3cb33e18a57812eded50c287029c9
Author: Erik Martin-Dorel <erik.martin-do...@irit.fr>
Commit: Erik Martin-Dorel <erik.martin-do...@irit.fr>

    fix: (opam-switch--reset-env) unexpectedly cleared exec-path
    
    Close #13
---
 NEWS.md             | 1 +
 opam-switch-mode.el | 6 +++++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/NEWS.md b/NEWS.md
index 6fc856860a..ae241b87b0 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -14,6 +14,7 @@ The format is based on [Keep a 
Changelog](https://keepachangelog.com/en/1.0.0/).
 ### Fixed
 
 - **README.md**: Markdown badges
+- (opam-switch--reset-env) unexpectedly cleared exec-path, closes 
[#13](https://github.com/ProofGeneral/opam-switch-mode/issues/13)
 
 ### Changed
 
diff --git a/opam-switch-mode.el b/opam-switch-mode.el
index 05b3a4d193..9ec49d7f94 100644
--- a/opam-switch-mode.el
+++ b/opam-switch-mode.el
@@ -238,7 +238,11 @@ Reset variable `exec-path' and all environment variables 
to the values
 they had in this Emacs session before the first chosen opam
 switch overwrote them."
   (mapc (lambda (x) (setenv (car x) (cadr x))) opam-switch--saved-env)
-  (setq exec-path opam-switch--saved-exec-path)
+  (when opam-switch--saved-exec-path
+    ;; it's nil if one enables `opam-switch-mode'
+    ;; but does not call `opam-switch-set-switch'
+    ;; cf. https://github.com/ProofGeneral/opam-switch-mode/issues/13
+    (setq exec-path opam-switch--saved-exec-path))
   (setq opam-switch--saved-env nil)
   (setq opam-switch--saved-exec-path nil))
 

Reply via email to