I've encountered two very nice modes when it comes to developing C++ in Emacs. First we have flycheck-mode which on the fly checks the syntax of my code using various backends such as clang or gcc. The second one is company-mode which provides auto-completion in various situations, function names, method names, object fields, using a back end such as clang.

The problem is that both likes to rewrite the contents of the buffer. Company-mode adds it's list of completions while flycheck-mode adds underscoring to problematic parts of the code. These collide for example when a user starts typing a function name, company-mode pops up the completion list, the user reads the available options which disappear half a second later because flycheck rewrites the display due to the incorrect, half-written, function call.

After further investigation it turns out that this bug only occurs in terminal emacs when the buffer can't be displayed in a single window. A video of the bug can be found on youtube: https://www.youtube.com/watch?v=Lg40mtSk_u8

So is it possible to make these two modes play nicely together? Or are there any good alternative modes that do work together and provide the same functionality?

  • If you use Helm, you can use helm-company, replace company-complete with helm-company and company candidates are displayed in a Helm buffer instead.
    – Tu Do
    Commented Nov 21, 2014 at 15:48

1 Answer 1


This issue is the result of a faulty interaction between overlays with before-string/after-string properties whose contents have a display property attached. It was been reported to Emacs as bug #19201, and since been fixed in Emacs. The fix will make it into the next release.

Meanwhile, you can work around this issue by disabling Flycheck's fringe indicators in TTY frames with the following code in your init file:

(add-hook 'flycheck-mode-hook
          (lambda ()
            (when (display-graphic-p)
              (setq-local flycheck-indication-mode nil))))

You will not see any difference, since TTY frames do not have a fringe anyway, but this code will prevent Flycheck from setting a before-string on its overlay, thus avoiding conflicts with the Company overlays.

  • It appears that this only happens when emacs is in a terminal and when the window doesn't contain the whole file. I've made a bug report here with the details you requested: github.com/flycheck/flycheck/issues/526
    – Rovanion
    Commented Nov 24, 2014 at 13:59
  • @Rovanion I reverted your edit. Aside from being wrong (you need to quote the body form with eval-after-load), I'd like to have an answer that reflects the current state of the art, and not that of some arbitrary older release.
    – user227
    Commented Nov 28, 2014 at 10:42
  • Wrong? It worked just fine in my emacs. Only changed the variable when in terminal emacs.
    – Rovanion
    Commented Nov 28, 2014 at 15:26
  • 1
    @Dmitry Good point. I updated the answer accordingly. I'm using flycheck-mode-hook, though, for Flycheck will also check buffers that have no backing file.
    – user227
    Commented Nov 28, 2014 at 23:14
  • 2
    Shouldn't this read unless instead of when?
    – Clément
    Commented Apr 16, 2015 at 19:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.