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

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

[nongnu] elpa/opam-switch-mode 9d8aa6d5dc 08/31: display current switch


From: ELPA Syncer
Subject: [nongnu] elpa/opam-switch-mode 9d8aa6d5dc 08/31: display current switch in menu
Date: Mon, 14 Nov 2022 08:59:59 -0500 (EST)

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

    display current switch in menu
---
 opam-mode.el | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/opam-mode.el b/opam-mode.el
index 4c2364ec1d..72bc71513d 100644
--- a/opam-mode.el
+++ b/opam-mode.el
@@ -211,6 +211,13 @@ switch overwrote them."
   (setq opam-saved-exec-path nil))
 
 
+(defun opam-get-current-switch ()
+  "Return name of current switch or \"<none>\"."
+  (let ((current-switch (getenv "OPAM_SWITCH_PREFIX")))
+    (if current-switch
+         (file-name-nondirectory current-switch)
+      "<none>")))
+
 (defun opam-set-switch (switch-name)
   "Chose and set an opam switch.
 Set opam swith SWITCH-NAME, which must be a valid opam switch
@@ -234,10 +241,7 @@ not any other shells outside emacs."
   (interactive
    (let* ((switches (opam-get-switches))
           (default (car switches))
-          (current-switch (getenv "OPAM_SWITCH_PREFIX")))
-     (if current-switch
-         (setq current-switch (file-name-nondirectory current-switch))
-       (setq current-switch "<none>"))
+          (current-switch (opam-get-current-switch)))
      (list
       (completing-read
        (format "current switch %s; switch to (empty to reset): " 
current-switch)
@@ -262,7 +266,12 @@ not any other shells outside emacs."
 (defun opam-menu-items ()
   "Create list or opam switches as menu items for `easy-menu'."
   (nconc
-   ;; first the list with all the real opam switches
+   ;; first the current switch as info
+   '(["current: " nil
+      :active t
+      :suffix (opam-get-current-switch)
+      :help "Shows the currently selected opam switch"])
+   ;; then the list with all the real opam switches
    (mapcar
     (lambda (switch)
       (vconcat



reply via email to

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