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
Don't activate eglot in invisible buffers #233
Conversation
1. To correctly fontify each diff hunk (e.g. on `vc-annotate-show-diff-revision-at-line`) `diff-syntax-fontify-hunk ` creates invisible buffers containing specific file revision and enables major-mode of the file. 2. After Eglot sends `didOpen` to server and server sends diagnostics for that specific version of the file. 3. Diagnostic info is displayed in real file buffer. It leads to wrong flymake error reports.
I'm not sure I understand what's going on here. How can an "insivisible" buffer have a Can you provide an Emacs -Q recipe for triggering this? |
Sure. Emacs 27.0.50 emacs-mirror/emacs@af04738 Prepare test file. I use mercurial, but it can be git or another VCS supported by Emacs VC:
Now in
Now there is 1 flymake error:
|
@muffinmad, I'm not able to reproduce the bug by following your detailed description. Unfortunately, it's been a long time since you reported the issue. Do you still see the problem? (Hopefully, it solved itself, and doing nothing was a good strategy.) |
@nemethf Patch is outdated indeed. But I can still reproduce the bug. Are you on Emacs 27? |
Patch is updated to handle
|
I don't know what I did wrong first time, but I am now able to reproduce the problem. I think the culprit is in diff-syntax-fontify-props, which has the following: (let (...
(buffer-file-name file)) After these lines two buffers have the same value for buffer-file-name. Which is strange, but I guess it's not necessarily a bug in diff-mode.el. There are different ways to modify Eglot to cope with the situation, and it's a personal preference, but I think this PR can be improved to be more clear. Currently, Eglot determines whether a buffer is "normal" by checking buffer-file-name. We know now that this is not enough. So instead, we should introduce a new function (Additionally, trailing whitespace is not good, but removing it is an independent change, and should not be part of this PR.) |
We should double check, but your proposed fix isn't too bad (with some better name, not necessarily the one I suggested). |
|
Two buffers with different content have the same buffer-file-name.
Sounds great. I'll continue to work on it.
Got it. |
I asked it here: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=39190 |
Customizing A good long term solution would be fixing #218, because if Eglot starts to manage a buffer only when the buffer is visible, this issue won't happen. By the way, Stefan suggested a similar solution in "emacs.bugs". However, I'm not going to work on #218 in the foreseeable future. @muffinmad, would you like to work on the eglot--manageable-buffer-p approach as a interim solution? (Or on #218? But that surely requires your copyright paperwork sorted out.) |
That feature is too cool to turn it off. I rather use locally patched eglot :) Meanwhile there are some nice patches in you bug report so maybe it will be fixed in Emacs 27.
Possibility to start eglot in visible buffers only must be optional, isn't it? Like
Sure, I'll try. And copyright paperwork is done already. |
Can't reproduce this on recent Emacs master and 27 pretest. Looks like the problem is fixed in Emacs. Closing this. Thanks @nemethf ! |
To correctly fontify each diff hunk (e.g. on
vc-annotate-show-diff-revision-at-line
)diff-syntax-fontify-hunk
creates invisible buffers containing specific file revision and enables major-mode of the file.Eglot sends
didOpen
to server and server sends diagnostics for that specific version of the file.Diagnostic info is displayed in real file buffer.
It leads to wrong flymake error reports.