New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to run Flycheck after buffer switch #1297

Closed
raxod502 opened this Issue Aug 1, 2017 · 4 comments

Comments

Projects
None yet
2 participants
@raxod502
Copy link
Contributor

raxod502 commented Aug 1, 2017

I'd like to have Flycheck run after a short delay (specifically, after flycheck-idle-change-delay) whenever I switch buffers.

The current behavior is that syntax checks occur only after modifications to the buffer, or after a save, as per the default setting of flycheck-check-syntax-automatically.

However, it often happens that I change some configuration externally, or I make modifications in another file. Then, when I switch back to an old buffer that is supposed to now have errors in it, Flycheck does not run another check. I have to manually edit the buffer or save it. My current workflow is to switch to a buffer, insert a character, delete it, and save—after that, Flycheck will show the errors. And I feel really dumb every time I do that.

I'd propose for a new value buffer-change to be added to flycheck-check-syntax-automatically, which would cause a syntax check to be run after flycheck-idle-change-delay (or an analogous variable), whenever the user switched buffers.

@fmdkdd

This comment has been minimized.

Copy link
Member

fmdkdd commented Aug 2, 2017

Thanks for the idea. I like it!

The only downside I'm seeing is that with this new setting, a syntax check would begin every time you switch to this buffer, even if the buffer hasn't changed, right?

But what if your configuration file hasn't changed either? You don't need to run the syntax check, but Flycheck cannot know because it has no knowledge of the dependencies between your buffers.

It looks like the correct solution here is to make Flycheck project-aware, which is out of scope for now.

However, your suggestion is a nice compromise to that. We don't need to know the dependencies, we just run the syntax check regardless.

I'd be wary about making this new option part of the default value for flycheck-check-syntax-automatically, but otherwise I'm okay offering it as a choice.

@raxod502

This comment has been minimized.

Copy link
Contributor

raxod502 commented Aug 2, 2017

I agree with all the things you have said. I might see if I can make a pull request (but that depends on how complicated it turns out to be).

@fmdkdd

This comment has been minimized.

Copy link
Member

fmdkdd commented Aug 2, 2017

@raxod502 Sure, that would be lovely. You can make an incomplete PR and we can answer any questions you might have in there directly.

raxod502 added a commit to raxod502/flycheck that referenced this issue Aug 26, 2017

Allow running syntax check after buffer switch
* Add new value `buffer-switch' to allowable values in
  `flycheck-check-syntax-automatically`, which allows the user to
  enable running a syntax check on a buffer switch (after a delay).
* Add new user option `flycheck-buffer-switch-delay', which customizes
  the delay between a buffer switch and the automatic syntax check.
* Introduce dependency on `switch-buffer-functions'.
* Use `switch-buffer-functions' to detect buffer switches.
* Add new functions `flycheck-handle-buffer-switch' and
  `flycheck-handle-idle-buffer-switch' to power the new
  syntax-checking functionality.

Fixes flycheck#1297.
@raxod502

This comment has been minimized.

Copy link
Contributor

raxod502 commented Aug 26, 2017

I have created pull request #1308 to implement this feature.

raxod502 added a commit to raxod502/flycheck that referenced this issue Mar 16, 2018

raxod502 added a commit to raxod502/flycheck that referenced this issue Mar 16, 2018

raxod502 added a commit to raxod502/flycheck that referenced this issue Mar 16, 2018

raxod502 added a commit to raxod502/flycheck that referenced this issue Mar 16, 2018

raxod502 added a commit to raxod502/flycheck that referenced this issue Mar 16, 2018

raxod502 added a commit to raxod502/flycheck that referenced this issue May 11, 2018

raxod502 added a commit to raxod502/flycheck that referenced this issue Jun 12, 2018

raxod502 added a commit to raxod502/flycheck that referenced this issue Jul 10, 2018

raxod502 added a commit to raxod502/flycheck that referenced this issue Jul 10, 2018

raxod502 added a commit to raxod502/flycheck that referenced this issue Dec 9, 2018

@fmdkdd fmdkdd closed this in 4b7b821 Dec 14, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment