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 and company interfer with each other in C++-mode with emacs in a terminal. #526

Closed
Rovanion opened this issue Nov 24, 2014 · 22 comments

Comments

@Rovanion
Copy link

Using the below example file in a terminal emacs which isn't able to display the whole file without scrolling:

#include <cmath>

int main(void){

}

double other(void){
    ;
    ;
    ; // This will disappear
    ;
    ;
    ;
    ;
    ;
    ;
    ;
    ;
    ;
    ;
    ;
    ;
    ;
    ;
}

With C++-mode, flycheck-mode and company-mode (with the clang backend) activated i get the following behaviour when typing in acos into the main function. Note that the company completion starts at one character to highlight the behaviour, though the behaviour is the same with company-minimum-prefix-length set to 1: https://www.youtube.com/watch?v=Lg40mtSk_u8

I'm running:
GNU Emacs 24.3.1 (i686-pc-linux-gnu, GTK+ Version 3.10.7) of 2014-03-07 on toyol, modified by Debian
Flycheck version: 0.21alpha1 (package: 20141020.724)
Company version: 0.8.8-cvs

@swsnr
Copy link
Contributor

swsnr commented Nov 24, 2014

@swsnr
Copy link
Contributor

swsnr commented Nov 24, 2014

@Rovanion I see. TTY frames are a different story.

You might try to update to Emacs 24.4, but I doubt that this will fix the issue. In fact, I'd not be surprised if it turns out that we can't fix this issue at all, at least in Company or Flycheck. The graphic capabilities of TTY frames are very limited, and I don't even dare to guess what insane hacks Company has to employ to show its popups there.

I don't know what could possibly cause this particular issue. I'm inviting @dgutov into this conversation. As the Company maintainer, he might be able to shed some light on this.

Don't have too much hope though that we are able to fix this issue.

Meanwhile, either use a GUI frame—which I'd recommend you anyway, regardless of this particular issue—or remove idle-change from flycheck-check-syntax-automatically, so that Flycheck does not check while you are typing anymore.

@dgutov
Copy link

dgutov commented Nov 25, 2014

You might try to update to Emacs 24.4, but I doubt that this will fix the issue.

It might; or if it doesn't, we probably should reduce this to a simple example and file a bug.

I don't even dare to guess what insane hacks Company has to employ to show its popups there.

No need to guess: just the same hack as in the GUI mode (a multiline overlay, starting at the end of the current line, with invisible set to t and after-string set to the contents of the covered lines modified to paint the popup over them). AFAIK, these display engine features should work the same in TTY as in GUI mode.

So, I believe your overlay somehow makes the after-string property of our overlay inactive. Looking at the code, nothing obvious jumps out at me.

@swsnr
Copy link
Contributor

swsnr commented Nov 25, 2014

@dgutov The point is that this only happens in TTY frames. I'm not able to re-produce it in a GUI frame, nor have I ever seen it despite using Flycheck and Company together every day.

@dgutov
Copy link

dgutov commented Nov 25, 2014

That would be a bug in the display engine as implemented in TTY frames, I guess.

@dgutov
Copy link

dgutov commented Nov 25, 2014

Especially if you yourself can reproduce it in a TTY frame.

@swsnr
Copy link
Contributor

swsnr commented Nov 25, 2014

@dgutov Interesting, I didn't try hitherto, but as a matter of fact, I can't reproduce the issue either on Emacs trunk.

@Rovanion Try to update to Emacs 24.4, or—if that doesn't help—build the current Emacs trunk from source and try it. If any of these fixes the issue, it's indeed an upstream bug in Emacs.

@Rovanion
Copy link
Author

@lunaryorn I'm able to reproduce the issue both with emacs compiled from the 24.4 release and from the master branch on savannah.

@dgutov
Copy link

dgutov commented Nov 25, 2014

@Rovanion Can you also reproduce it starting with HOME=/tmp emacs -Q, and installing only Flycheck and Company?

Is the problem the same across different text terminals (e.g. xterm, gnome-console and the ctrl+alt+f1 virtual console)?

@Rovanion
Copy link
Author

Yes, the issue is still present with only company and flycheck installed
running emacs as you described.

The result is the same in both urxvt, gnome-terminal, xterm and virtual
console.

2014-11-25 23:23 GMT+01:00 Dmitry Gutov notifications@github.com:

@Rovanion https://github.com/Rovanion Can you also reproduce it
starting with HOME=/tmp emacs -Q, and installing only Flycheck and
Company?

Is the problem the same across different text terminals (e.g. xterm,
gnome-console and the ctrl+alt+f1 virtual console)?


Reply to this email directly or view it on GitHub
#526 (comment).

@dgutov
Copy link

dgutov commented Nov 26, 2014

All right, I can reproduce that. Let's see if I can make a reduced test case.

@swsnr
Copy link
Contributor

swsnr commented Nov 26, 2014

@dgutov Do you think that it's an issue in Flycheck? I mean, I'm not doing anything special with overlays in Flycheck…

@dgutov
Copy link

dgutov commented Nov 27, 2014

@lunaryorn I don't think so, but let's wait for a more qualified response:

http://debbugs.gnu.org/cgi/bugreport.cgi?bug=19201

@dgutov
Copy link

dgutov commented Nov 27, 2014

And meanwhile, here's another workaround:

(setq flycheck-indication-mode nil) 

There are no fringes in TTY anyway.

@Rovanion
Copy link
Author

Thank you for the great follow-up on this bug report both of you!

@dgutov
Copy link

dgutov commented Nov 28, 2014

@Rovanion No problem.

@lunaryorn The bug is closed now, the fix will be in 24.5. But to be on the safe side, you may want to replace (when flycheck-indication-mode with (when (and flycheck-indication-mode (display-graphic-p).

@swsnr
Copy link
Contributor

swsnr commented Nov 28, 2014

@dgutov Thank you for reporting the issue to Emacs. I was quite surprised to learn that my use of before-string was not intended by the Emacs developers: I actually copied this approach from Flymake, and I'd never have though that code in a core library would violate some implicit assumptions of other code in Emacs. I should have know better…

Since this was really an upstream bug, I'm closing this issue as invalid. @Rovanion Thank your efforts in reporting this issue, particularly for the video.

@swsnr swsnr closed this as completed Nov 28, 2014
@dgutov
Copy link

dgutov commented Nov 28, 2014

code in a core library would violate some implicit assumptions of other code in Emacs

Eh, bugs happen. The usual way to add fringe indicators using overlays is definitely a hack (display on a string inside before-string? really?), most likely stemming from the fact that nobody hasn't been motivated enough to give the display engine a major rewrite, for decades.

That's what Eli's "Founding Fathers" remark refers to.

@swsnr
Copy link
Contributor

swsnr commented Nov 28, 2014

@dgutov Sorry, I meant no offence. I know that “bugs happen”.

I'd not have thought, however, that a core library would use Emacs in a way that it's not supposed to be used. See, you'd think that there is some kind of review process for patches landing in Emacs, but apparently I'm mistaken.

Another lesson that Emacs' own code is not always to be followed, I guess, even if it's as recent (relatively) as that code in Flymake.

I presume, though, that this hack is the only way to add fringe indicators with an overlay, isn't it?

@dgutov
Copy link

dgutov commented Nov 29, 2014

a core library would use Emacs in a way that it's not supposed to be used

You're assuming that it was known in advance that adding bitmap on a fringe using before-string was problematic.

you'd think that there is some kind of review process for patches landing in Emacs

There is. Even if a patch is installed by someone with commit access without discussion, IME it will at least be read through by someone else.

But anyway yes, many built-in packages are not ideal. You can plainly see lots of warnings during Emacs compilation, and, for example, cc-mode is known for lots of non-idiomatic approaches in its code.

this hack is the only way to add fringe indicators with an overlay, isn't it?

Yep, as far as I know. I also use it in diff-hl.

@swsnr
Copy link
Contributor

swsnr commented Nov 29, 2014

@dgutov Indeed, that was my assumption, also because Eli tracked it down so fast. But I see that it's a faulty assumption. I'm glad to see, though, that you are using the same approach. That makes me feel comfortable: If you are using it, it should be quite ok for my humble projects as well :)

Besides, better not get me started on CC Mode. It's currently giving me pleasures on its own right. Its insane source file tracking breaks on D Mode, and subsequently kills all other CC Mode derivates in the same session (e.g. PHP Mode). Took me a month, literally, to find that out.

@dgutov
Copy link

dgutov commented Nov 29, 2014

@lunaryorn

If you are using it, it should be quite ok for my humble projects as well :)

No need to be modest: the Flycheck codebase is larger than diff-hl and company combined. ;)

CC Mode... currently giving me pleasures on its own right

Right, I saw that bug after sending the previous response. There's been some movement in CC Mode in recent months, albeit slowly, since Stefan took an interest.

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

No branches or pull requests

3 participants