Skip to content
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

Flycheck mixes code and text in org buffer #3

Open
yantar92 opened this issue Oct 24, 2018 · 6 comments
Open

Flycheck mixes code and text in org buffer #3

yantar92 opened this issue Oct 24, 2018 · 6 comments

Comments

@yantar92
Copy link

When flycheck is enabled in the major mode of code blocks, it actually checks all the org buffer when in poly-org mode.
As a result, many flycheck errors are actually triggering on the text in buffer.

@vspinu
Copy link
Contributor

vspinu commented Oct 24, 2018

Right. Flycheck checks full buffers and. It doesn't understand mixed code. The fix might be simple if flycheck allows checking for regions then flycheck function could be re-bound to sniff only inner modes, but it would be very hard if there is no such provision.

@matthuszagh
Copy link

matthuszagh commented Nov 6, 2019

Uninformed question here: how hard would it be for inner mode buffers to only contain the text in that inner section rather than the full buffer text?

For instance, imagine you had some file, file.org:

file.org:

#+title: some title
some text
#+begin_src c
int main()
{}
#+end_src
other text

Where the file.org[c] file would only consist of

int main()
{}

It seems like this could solve a number of existing as well as potential issues related to the one brought up here and that wouldn't rely on the capabilities of external tools. I believe I experienced a thematically-similar issue when using aggressive-indent-mode with polymode, although it's been a while since I tried this. Code formatters come to mind as well.

I appreciate that I understand nothing of how polymode is implemented so please let me know if that's the case. However, I am curious about this.

@yantar92
Copy link
Author

yantar92 commented Nov 6, 2019

Polymode relies on indirect buffers. All the inner mode buffers are inirect buffers derived from the initial buffer. Unfortunately, all indirect buffers must contain all the text of the initial buffer and all the changes in the indirect buffers automatically propagate to the initial buffer. I don't know any obvious way to make the text in the indirrect buffers differ from the initial buffer as in your example.

@vspinu On a side note, I am currently working (very very slowly, though) on a way to achieve indirect buffer-like functionality, which operates on regions of text. How feasible would it be to adapt polymode to such kind of functionality?

@vspinu
Copy link
Contributor

vspinu commented Nov 7, 2019

That's for sure not possible and I don't believe it's useful. In most of the non-trivial cases code in one chunk depends on the code in previous chunks. So isolating it in separate buffer is useless even for the flycheck example here.

What flycheck support for polymode should do, is to send to flycheck a temporary buffer/file with all the other spans except of the curent mode's ones commented out. This part should be straightforward enough. Unfortunately I am so busy till the end of the year and maybe beyond that I won't be able to look at this any time soon.

@jilen
Copy link

jilen commented Nov 2, 2020

Is there a way to disable flycheck while editing chunks

@cpitclaudel
Copy link

cpitclaudel commented Mar 17, 2021

What flycheck support for polymode should do, is to send to flycheck a temporary buffer/file with all the other spans except of the curent mode's ones commented out.

I'd be happy to help with that. But commenting out may not be enough, since some checkers return errors as an offset from the start of the buffer, not as a line and column number.

Here's what I use for now, which disables Flycheck in indirect buffers.

(defun flycheck-buffer-not-indirect-p (&rest _)
  "Ensure that the current buffer is not indirect."
  (null (buffer-base-buffer)))

(advice-add 'flycheck-may-check-automatically
            :before-while #'flycheck-buffer-not-indirect-p)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants