jyp / dante

392 stars 51 forks source link

Enable/disable flycheck checker more idiomatically #116

Closed purcell closed 5 years ago

purcell commented 5 years ago

Flycheck can determine for itself whether the dante checker should be enabled, by supplying it with a :predicate function that returns t if and only dante-mode is active.

The dante checker is then simply added to the list of globally-available checkers, so that it works the same way as every other checker.

With this change, disabling dante-mode simply causes the next-best Haskell checker to be selected until dante-mode is re-enabled, which is the expected behaviour, while the user can still disable flycheck-mode in the buffer to stop checking entirely.

jyp commented 5 years ago

What about:

(flycheck-select-checker 'haskell-dante)

Should this be added in the user's config?

purcell commented 5 years ago

What about:

(flycheck-select-checker 'haskell-dante)

Should this be added in the user's config?

Nope, flycheck does that itself based on the major mode: it looks through the checkers list in sequence for haskell-mode checkers, and reaches the dante checker first. If the :predicate returns nil then it moves onto the next. So the add-to-list (which is a prepend operation by default) is all that's needed.

jyp commented 5 years ago

Thank you very much for this!