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

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

[nongnu] elpa/opam-switch-mode 5ac0375eca 1/4: feat: Add new hook opam-s


From: ELPA Syncer
Subject: [nongnu] elpa/opam-switch-mode 5ac0375eca 1/4: feat: Add new hook opam-switch-before-change-opam-switch-hook
Date: Tue, 11 Jul 2023 13:00:07 -0400 (EDT)

branch: elpa/opam-switch-mode
commit 5ac0375ecaa38ab4d829b2d60a379d986a8f9f42
Author: Erik Martin-Dorel <erik@martin-dorel.org>
Commit: Erik Martin-Dorel <erik@martin-dorel.org>

    feat: Add new hook opam-switch-before-change-opam-switch-hook
    
    (opam-switch-set-switch) now calls:
    
    - (run-hooks 'opam-switch-before-change-opam-switch-hook) beforehand
    - (run-hooks 'opam-switch-change-opam-switch-hook) afterwards
    
    The former happens to be required in the case of merlin, otherwise
    we would lose track of the path of the ocamlmerlin server to kill.
    
    Related: https://github.com/ProofGeneral/opam-switch-mode/issues/9
---
 NEWS.md             |  3 +++
 opam-switch-mode.el | 11 ++++++++---
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/NEWS.md b/NEWS.md
index 536ca5b248..f6ecd163ae 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -9,6 +9,9 @@ The format is based on [Keep a 
Changelog](https://keepachangelog.com/en/1.0.0/).
 
 ### Added
 
+- New hook: opam-switch-before-change-opam-switch-hook
+- (opam-switch-set-switch): Call (run-hooks 
'opam-switch-before-change-opam-switch-hook) before changing the env
+
 ### Fixed
 
 ### Changed
diff --git a/opam-switch-mode.el b/opam-switch-mode.el
index 3dbde4af14..08f7c18634 100644
--- a/opam-switch-mode.el
+++ b/opam-switch-mode.el
@@ -81,10 +81,14 @@ without color, non-ascii arrow symbols and that it is in 
English.
 Otherwise parsing the output of opam commands won't work."
   :type '(repeat string))
 
+(defcustom opam-switch-before-change-opam-switch-hook nil
+  "Hook run before the opam switch changes.
+This is used, for instance, to let merlin kill the ocamlmerlin
+background process before the opam switch changes."
+  :type 'hook)
+
 (defcustom opam-switch-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."
+  "Hook run after the opam switch changes."
   :type 'hook)
 
 ;;; Code:
@@ -303,6 +307,7 @@ not any other shells outside Emacs."
        switches nil t "" 'opam-switch--switch-history nil))))
   (when (and (equal switch-name "") (not opam-switch--saved-env))
     (error "No saved opam environment, cannot reset"))
+  (run-hooks 'opam-switch-before-change-opam-switch-hook)
   (if (equal switch-name "")
       (opam-switch--reset-env)
     (let ((output-string (opam-switch--command-as-string "env" switch-name t))



reply via email to

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