1

When editing a large file, flycheck-mode often takes 3-4 seconds to complete if an error "spills" over into the rest of the source file such that lots of lines are tagged with an error.

enter image description here

How do I limit the number of errors that the mode highlights such that it prioritizes the current buffer location?

malthe
  • 1,237
  • 13
  • 25

1 Answers1

3

Flycheck maintainer here.

You cannot “limit” error reporting currently in an easy way. At best, you can use a custom function for flycheck-process-error-functions, but that won't help you if the lag comes from something else, like error parsing.

And in general, I'd rather like to fix these lags than work around, if possible. Please open an issue at https://github.com/flycheck/flycheck/issues. Please add your Emacs version to the issue, and the amount of errors reported by Flycheck.

If possible, also give me the source file in private. You can find a mail address in the Github profile of Flycheck.

  • I have added a screenshot to my question that shows a simple example in Python. The fact that I'm starting to write a tuple should not "spill over" to the rest of the module. I have seen the same behavior when editing C code. – malthe Sep 17 '14 at 08:57
  • 1
    @malthe That is **expected** behaviour, and outside of Flycheck's control in any case. You see whatever the syntax checker reports, and strictly speaking your invalid tuple renders the entire module invalid, so the subsequent syntax errors are reasonable. Anyhow, an example as simple as that would not case a four seconds delay in Flycheck. –  Sep 17 '14 at 09:25
  • It's not reasonable because a module can be thousands of lines long. But I understand that it's not Flycheck that is to blame. – malthe Sep 17 '14 at 12:01
  • 1
    @malthe So what? Whether it's a thousand lines or just five, invalid syntax is invalid syntax, in either case. The editor can't know that you about to close the parenthesis right away, nor can it guess where your half-finished tuple is supposed to end to adjust the error reporting accordingly. –  Sep 17 '14 at 12:07
  • @lunaryorn, you could try https://github.com/pydata/pandas/blob/master/pandas/tests/test_frame.py, it's a 14k lines and ~500k bytes file that is not really PEP8 compliant (flake8 reports ~3k errors). First thing I do when I open it to fix/add something is spam C-g to make flycheck stop and then turn it off completely, because these timings are not really edit-friendly: https://gist.github.com/immerrr/d188aab1861d38b9232b – immerrr Sep 18 '14 at 10:07
  • @immerrr Thank you for profiling. It seems that the error filtering *and* the overlaying take much time. We can optimize the overlays probably, but I am not so sure whether we can speed up filtering. Would you mind to open an issue for Flycheck? We probably need to discuss other solutions, such as disabling Flycheck automatically if a syntax check found too many errors. –  Sep 18 '14 at 10:34
  • @lunaryorn, I've noticed #154 and #179 reporting similar (same) issues, I'll follow those more closely tomorrow in the morning and report if I'll have anything to add to that. – immerrr Sep 18 '14 at 13:28
  • @immerrr I'm now tracking this issue at https://github.com/flycheck/flycheck/issues/476. Please comment on this issue if you have good ideas on how to handle situations like this. –  Sep 20 '14 at 09:15