NonGNU-devel ELPA - opam-switch-mode

opam-switch-mode

Description
Select OCaml opam switches via a menu
Latest
opam-switch-mode-1.8snapshot0.20230802.91729.tar (.sig), 2024-Mar-31, 40.0 KiB
Maintainer
<proof-general-maintainers@groupes.renater.fr>
Atom feed
opam-switch-mode.xml
Website
https://github.com/ProofGeneral/opam-switch-mode
Browse ELPA's repository
CGit or Gitweb
Badge

To install this package from Emacs, use package-install or list-packages.

Full description

opam-switch-mode

NonGNU ELPA MELPA Stable MELPA

Provide a command opam-switch-set-switch to change the opam switch of the running Emacs session, and a minor mode opam-switch-mode to select the opam switch via a (menu-bar or mode-bar) menu.

The menu is generated each time the minor mode is enabled and contains the switches that are known at that time. If you create a new switch, re-enable the minor mode to get it added to the menu. The menu contains an additional entry "reset" to reset the environment to the state when Emacs was started.

Installing opam-switch-mode

We recommend to install this mode from either the NonGNU ELPA or the MELPA repository of Emacs packages. In the sequel, we assume you have already set up those in your .emacs.

If you use the use-package macro, the recommended configuration is as follows:

(use-package opam-switch-mode
  :ensure t
  :hook
  ((coq-mode tuareg-mode) . opam-switch-mode))

If you don't use use-package, do the following instead:

(add-hook 'coq-mode-hook #'opam-switch-mode)
(add-hook 'tuareg-mode-hook #'opam-switch-mode)

so that the minor mode is automatically enabled when coq-mode or tuareg-mode is on, see also opam-switch-mode aware modes.

Command opam-switch-set-switch

Invoke with M-x opam-switch-set-switch RET.

Choose and set an opam switch.

Set opam switch SWITCH-NAME, which must be a valid opam switch name. When called interactively, the switch name must be entered in the minibuffer, which forces completion to a valid switch name or the empty string.

Setting the opam switch for the first time inside Emacs will save the current environment. Using the empty string for SWITCH-NAME will reset the environment to the saved values.

The switch is set such that all process invocations from Emacs respect the newly set opam switch. In addition to setting 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).

Just before the switch is changed, opam-switch-before-change-opam-switch-hook runs. After the switch is changed, opam-switch-change-opam-switch-hook runs. One of these can be used to inform other modes that run background processes that depend on the currently active opam switch.

For obvious reasons, opam-switch-set-switch will only affect Emacs and not any other shells outside Emacs.

opam-switch-mode aware modes

  • coq-mode from proof-general can kill the Coq background process when the opam switch changes, see option coq-kill-coq-on-opam-switch.
  • tuareg-mode from tuareg can kill the OCaml background process when the opam switch changes, see option tuareg-kill-ocaml-on-opam-switch.
  • merlin-mode from merlin can kill the underlying Merlin server when the opam switch changes, see option merlin-stop-server-on-opam-switch.

Old versions

opam-switch-mode-1.8snapshot0.20230726.204116.tar.lz2023-Jul-277.68 KiB
opam-switch-mode-1.7snapshot0.20230726.102433.tar.lz2023-Jul-267.73 KiB
opam-switch-mode-1.7snapshot0.20230714.95451.tar.lz2023-Jul-147.61 KiB
opam-switch-mode-1.6snapshot0.20230713.94852.tar.lz2023-Jul-137.44 KiB
opam-switch-mode-1.6snapshot0.20230712.214403.tar.lz2023-Jul-137.43 KiB
opam-switch-mode-1.5snapshot0.20230711.212136.tar.lz2023-Jul-127.35 KiB
opam-switch-mode-1.5snapshot0.20230711.193827.tar.lz2023-Jul-117.30 KiB
opam-switch-mode-1.2snapshot0.20230710.111042.tar.lz2023-Jul-106.66 KiB
opam-switch-mode-1.2snapshot0.20230628.222149.tar.lz2023-Jun-296.37 KiB
opam-switch-mode-1.0snapshot0.20230620.153405.tar.lz2023-Jun-205.57 KiB

News

Changelog

All notable changes to opam-switch-mode will be documented in this file, in reverse chronological order.

The format is based on Keep a Changelog.

[Unreleased]

Added
Fixed
Changed
Removed

[1.7] - 2023-07-26

Changed
  • README.md: Mention Tuareg and Merlin, regarding opam-switch-mode support
  • release.sh: Remove noise (empty headings) in NEWS.md at release time
  • (opam-switch--get-switches): Use command opam switch -s, so we avoid regexp filtering code, closes #15

[1.6] - 2023-07-14

Added
  • Use command opam env --switch=$it --set-switch, so the env var $OPAMSWITCH is also set

[1.5] - 2023-07-12

Changed
  • README.md: Use vanilla (not GitHub-flavored) Markdown syntax for snippets
  • Replace (redraw-display) with (force-mode-line-update t)
  • Memoize (opam-switch-mode-lighter) to speed-up mode-line updates

[1.4] - 2023-07-11

Added
  • (opam-switch-mode-lighter): Indicate the switch name in the minibuffer, closes #11
Changed
  • README.md: Document the feature from [1.3]

[1.3] - 2023-07-11

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

[1.2] - 2023-07-11

Added
  • NEWS.md: Changelog
Fixed
  • README.md: Markdown badges
  • (opam-switch--reset-env) unexpectedly cleared exec-path, closes #13
  • (opam-switch--get-current-switch) returned "_opam" for local switches
  • (opam-switch--set-env) raised "No opam-root directory in PATH" for local switches, closes #12
Changed
  • Replace menu-bar's name (s/Opam-switch/OPSW/) so it matches mode-bar's name
  • Change mode-bar's first element, so it expands to "OPSW - Opam Switch Mode"
  • release.sh: auto-update NEWS.md

[1.1] - 2023-06-20

Added
  • release.sh: new script
Fixed

[1.0] - 2022-11-15

  • Initial release, distributed on MELPA.