[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/opam-switch-mode 8b8670ca8b 1/3: feat(opam-switch-mode-lig
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/opam-switch-mode 8b8670ca8b 1/3: feat(opam-switch-mode-lighter): Show the switch name in the mode-bar |
Date: |
Tue, 11 Jul 2023 16:00:14 -0400 (EDT) |
branch: elpa/opam-switch-mode
commit 8b8670ca8b4d1115fe2d2f0295a4e5ca969714a0
Author: Erik Martin-Dorel <erik.martin-dorel@irit.fr>
Commit: Erik Martin-Dorel <erik@martin-dorel.org>
feat(opam-switch-mode-lighter): Show the switch name in the mode-bar
& workaround the fact that the frames are not redisplayed just after
a click on the menu (reproduced with GNU Emacs 27.1 under Debian 11)
Close #11
---
NEWS.md | 2 ++
opam-switch-mode.el | 16 +++++++++++++---
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/NEWS.md b/NEWS.md
index 7f761e96c4..5403793e64 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -9,6 +9,8 @@ The format is based on [Keep a
Changelog](https://keepachangelog.com/en/1.0.0/).
### Added
+- (opam-switch-mode-lighter): Indicate the switch name in the minibuffer,
closes [#11](https://github.com/ProofGeneral/opam-switch-mode/issues/11)
+
### Fixed
### Changed
diff --git a/opam-switch-mode.el b/opam-switch-mode.el
index d6b4c2e9e3..c5432c9521 100644
--- a/opam-switch-mode.el
+++ b/opam-switch-mode.el
@@ -344,13 +344,16 @@ not any other shells outside Emacs."
(mapcar
(lambda (switch)
`[,switch
- (opam-switch-set-switch ,switch)
+ (progn (opam-switch-set-switch ,switch)
+ (redraw-display))
:active t
:help ,(concat "Select opam switch \"" switch "\"")])
(opam-switch--get-switches))
;; now reset as last element
'(
- ["reset" (opam-switch-set-switch "")
+ ["reset"
+ (progn (opam-switch-set-switch "")
+ (redraw-display))
:active opam-switch--saved-env
:help "Reset to state when Emacs was started"])))
@@ -371,12 +374,19 @@ is automatically created by `define-minor-mode'."
:label "OPSW")
(opam-switch--menu-items))))
+(defun opam-switch-mode-lighter ()
+ "Return the lighter for opam-switch-mode which indicates the current switch."
+ (let* ((current-switch (opam-switch--get-current-switch))
+ ;; handle the case of local switches for better UX
+ (shortened (replace-regexp-in-string ".*/" "…/" current-switch t t)))
+ (format " OPSW-%s" shortened)))
+
;;;###autoload
(define-minor-mode opam-switch-mode
"Toggle opam-switch mode.
The mode can be enabled only if opam is found and \"opam var root\" succeeds."
;; FIXME: Should we include the current switch in the lighter?
- :lighter " OPSW"
+ :lighter (:eval (opam-switch-mode-lighter))
(if (not opam-switch-mode)
(opam-switch--reset-env)
(condition-case sig