Emacs: new minor mode for opam users
Dear all,
If you happen to use use several opam switches and Emacs as an IDE: you may be interested in opam-switch-mode (which overlaps tuareg-mode’s M-x tuareg-opam-update-env
function but provides several additional features).
To be more precise:
- this minor mode requires GNU Emacs 25.1 and is available in MELPA, MELPA Stable, NonGNU-devel, NonGNU;
- it displays the currently chosen switch in the mode-line;
- it provides an OPSW menu-bar (also working in TTY) and an OPSW mode-bar menu, as well as a function
M-x opam-switch-set-switch
; - all of these allow to select a regular opam switch or a local opam switch;
- they trigger before/after the opam switch change, the functions registered in the hooks
'opam-switch-before-change-opam-switch-hook
and'opam-switch-change-opam-switch-hook
- these hooks are internally used by Tuareg, Merlin (or ProofGeneral for Coq) to kill the OCaml toplevel or the Merlin server: so that the next eval or save action uses the appropriate binary from the new switch;
- and finally, the minor mode stores the initial environment (before the mode is enabled), providing a Reset feature to backtrack to the initially chosen switch.
Here is a screenshot of the opam-switch-mode in GNU Emacs 27.1:
Happy hacking!
Erik Martin-Dorel, for the opam-switch-mode dev team