Skip to content

Commit 88533b8

Browse files
committed
fix: Apply review suggestions by @monnier
1 parent 7212437 commit 88533b8

File tree

2 files changed

+22
-29
lines changed

2 files changed

+22
-29
lines changed

CHANGES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ unreleased
1717
behavior can be enabled permanently by customizing
1818
`merlin-construct-with-local-values` (#1644)
1919
- emacs: add support for opam-switch-mode (#1654, fixes #1591)
20+
To fully benefit from `M-x opam-switch-mode`, the Merlin command
21+
must be a filename, e.g., `(setq merlin-command "ocamlmerlin")`.
2022

2123
merlin 4.9
2224
==========

emacs/merlin.el

Lines changed: 20 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -612,41 +612,32 @@ argument (lookup appropriate binary, setup logging, pass global settings)"
612612
(kill-local-variable 'merlin-erroneous-buffer)))))
613613

614614
(defcustom merlin-stop-server-on-opam-switch t
615-
"If t, stop ocamlmerlin server before the opam switch changes.
616-
If `(opam-switch-mode)' is loaded and the user changes the opam
617-
switch using `opam-switch-set-switch' or an `\"OPSW\"' menu, this
618-
option asks to stop the merlin server process, so that the next
619-
merlin command starts a new server, typically with a different
620-
merlin version from a different opam switch.
621-
622-
Based on the minor mode `opam-switch-mode', see:
623-
https://github.com/ProofGeneral/opam-switch-mode
624-
625-
Note: `(opam-switch-mode)' expects `merlin-command' to be `\"ocamlmerlin\"'."
626-
:group 'merlin :type 'boolean)
627-
628-
(defun merlin-stop-server-on-opam-switch ()
629-
"Stop ocamlmerlin before the opam switch changes.
615+
"If t, stop the Merlin server before the opam switch changes.
616+
If the user changes the opam switch using `opam-switch-set-switch'
617+
or an `\"OPSW\"' menu from `opam-switch-mode', this option asks to
618+
stop the Merlin server process, so that the next Merlin command
619+
starts a new server, typically with a different Merlin version
620+
from a different opam switch.
621+
622+
See https://github.com/ProofGeneral/opam-switch-mode
623+
624+
Note: `opam-switch-mode' triggers automatic changes of `exec-path',
625+
so to fully benefit from this feature, you should set `merlin-command'
626+
to a basename, typically: `(setq merlin-command \"ocamlmerlin\")'."
627+
:type 'boolean)
628+
629+
(defun merlin--stop-server-on-opam-switch ()
630+
"Stop the Merlin server before the opam switch changes.
630631
This function is for the `opam-switch-mode' hook
631632
`opam-switch-before-change-opam-switch-hook', which runs just
632-
before the user changes the opam switch through
633-
`opam-switch-mode'.
634-
635-
If `merlin-stop-server-on-opam-switch' is t, then the merlin
636-
server process is stopped, so that the next merlin command starts
637-
a new server, typically with a different merlin version from a
638-
different opam switch.
639-
640-
Based on the minor mode `opam-switch-mode', see:
641-
https://github.com/ProofGeneral/opam-switch-mode
642-
643-
Note: `(opam-switch-mode)' expects `merlin-command' to be `\"ocamlmerlin\"'."
633+
before the user changes the opam switch through `opam-switch-mode'."
644634
(when (and merlin-mode merlin-stop-server-on-opam-switch)
645-
(condition-case sig
635+
(condition-case _sig
646636
(merlin-stop-server)
647637
(t (message "Info: (merlin-stop-server) failed in the previous opam switch")))))
648638

649-
(add-hook 'opam-switch-before-change-opam-switch-hook #'merlin-stop-server-on-opam-switch t)
639+
(add-hook 'opam-switch-before-change-opam-switch-hook
640+
#'merlin--stop-server-on-opam-switch t)
650641

651642
;;;;;;;;;;;;;;;;;;;;
652643
;; FILE SWITCHING ;;

0 commit comments

Comments
 (0)