flycheck / flycheck-ocaml

OCaml support for Flycheck using Merlin
GNU General Public License v3.0
22 stars 6 forks source link

Use "command priority" of merlin-mode to handle racy situations #4

Closed let-def closed 9 years ago

let-def commented 9 years ago

The fix for handling competing access to merlin. The idea is that flycheck-ocaml indicates its low priority and if merlin can't satisfy the request, merlin-cancelled will be signaled (only merlin-sync-to-point can fail).

Note the (defvar merlin-command-priority): the file is lexically-scoped, but merlin-mode expects this setting to be dynamically redefined. Using a defvar seems to be the normal way to recover dynamic scoping.

swsnr commented 9 years ago

I'm unsure about this defvar thing, but other than that it looks good.

But I understand that this is a fairly recent feature in Merlin as well. Don't we need to update the Package-Requires then? I'd like to make sure that users who install from MELPA Stable get a consistent set of dependencies.

let-def commented 9 years ago

I agree it's strange. When I tried on my setup, it was once ignored by emacs, which considered merlin-command-priority has a normal lexically scoped variable. Of course there was a reason, I am almost sure I mixed outdated elc files, but just to avoid this fragility, I preferred to repeat the defvar definition, so that the compiler is less sensitive to scope.

This will also be the case for users having a non git version of merlin, but the nice thing is that nothing in the code refers to new definitions, so it's a transparent dropin, the merlin-command-priority will just be ignored by older versions.

swsnr commented 9 years ago

@def-lkb So flycheck-ocaml will continue to work with older Merlin versions that do not provide this new option? That's cool, and a good reason to define the variable explicitly. Thanks!

swsnr commented 9 years ago

@def-lkb Merged! Thanks for your help and your patch for this problem, it's greatly appreciated! And thanks for Merlin, it makes OCaml in Emacs insanely awesome! It's just a shame that I don't get to do any OCaml anymore :(

let-def commented 9 years ago

Thank you, well don't despair, you might have other occasions to do OCaml, and merlin will be even more awesome at that point :D.