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

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

[nongnu] elpa/opam-switch-mode d7ccecbf51 11/31: reset proof shell in Pr


From: ELPA Syncer
Subject: [nongnu] elpa/opam-switch-mode d7ccecbf51 11/31: reset proof shell in Proof General via a hook function
Date: Mon, 14 Nov 2022 09:00:00 -0500 (EST)

branch: elpa/opam-switch-mode
commit d7ccecbf512b480a5814a7801fd51470f23366e8
Author: Hendrik Tews <Hendrik.Tews@kernkonzept.com>
Commit: Hendrik Tews <Hendrik.Tews@kernkonzept.com>

    reset proof shell in Proof General via a hook function
---
 README.md    |  9 +++++++++
 opam-mode.el | 14 +++++++++++++-
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 590ecd24fd..c5fe341420 100644
--- a/README.md
+++ b/README.md
@@ -32,5 +32,14 @@ environment variables such as PATH and CAML_LD_LIBRARY_PATH, 
this
 also sets `exec-path`, which controls emacs' subprocesses
 (`call-process`, `make-process` and similar functions).
 
+When the switch is changed, `opam-change-opam-switch-hook` runs. This
+can be used to inform other modes that may run background processes
+that depend on the currently active opam switch.
+
 For obvious resons, `opam-set-switch` will only affect emacs and
 not any other shells outside emacs.
+
+## Opam mode aware modes
+
+- Proof General can kill the coq background process, when the
+  opam switch changes, see `coq-kill-coq-on-opam-switch`.
diff --git a/opam-mode.el b/opam-mode.el
index 945062c413..967408f824 100644
--- a/opam-mode.el
+++ b/opam-mode.el
@@ -79,6 +79,13 @@ Otherwise parsing the output of opam commands won't work."
   :group 'opam-mode
   :type '(repeat string))
 
+(defcustom opam-change-opam-switch-hook nil
+  "Hook run when the opam switch changes.
+This is used, for instance, to let Proof General kill the coq
+background process when the opam switch changes."
+  :group 'opam-mode
+  :type '(repeat function))
+  
 
 ;;; Code
 
@@ -245,6 +252,10 @@ also sets `exec-path', which controls emacs'
 subprocesses (`call-process', `make-process' and similar
 functions).
 
+When the switch is changed, `opam-change-opam-switch-hook' runs. This
+can be used to inform other modes that may run background processes
+that depend on the currently active opam switch.
+
 For obvious resons, `opam-set-switch' will only affect emacs and
 not any other shells outside emacs."
   (interactive
@@ -268,7 +279,8 @@ not any other shells outside emacs."
       (setq opam-env (car (read-from-string output-string)))
       (unless opam-saved-env
         (opam-save-current-env opam-env))
-      (opam-set-env opam-env))))
+      (opam-set-env opam-env)))
+  (run-hooks 'opam-change-opam-switch-hook))
 
 
 ;;; minor mode, keymap and menu



reply via email to

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