0

I'm currently seeing a display problem in Magit. For a while I've seen that when I do magit-status, the diffs are no longer highlighted. I didn't care for a while, thinking it was the theme I've been using, but today I tried other themes and in all of them there's no highlighting. I installed solarized-dark-theme which is used in the screenshots shown here, but I don't have the highlighting:

enter image description here

Is there any setting I need to turn on? When searching I couldn't find any references to a similar problem.

P.S. I'm using: GNU Emacs 25.3.1 (x86_64-apple-darwin17.4.0, NS appkit-1561.20 Version 10.13.3 (Build 17D47)) of 2018-02-08

and magit-version is: Magit 2.11.0-510-g1c4fa9b1, Git 2.13.6 (Apple Git-96), Emacs 25.3.1, darwin.

Update

Thanks @tarsius, now I know this is an issue specific to my configuration and not an issue with magit or the themes themselves, it works just fine when using magit-emacs-Q-command. I will try to "bisect" my configuration to find the issue but if someone can easily point what's wrong with my configuration will be helpful. This is my init.el.

Update #2

Seem's that the conflicting setting is (add-hook 'font-lock-mode-hook 'hc-highlight-tabs), I use this to see the tab character in files. Is there any workaround to make it co-exist with magit?

Thanks!

  • Please start by trying to reproduce the issue following the instructions in magit.vc/manual/magit/Debugging-Tools.html. – tarsius Feb 10 '18 at 17:34
  • Thanks it turns out that it works well when only loading magit and the theme, clearly I have a conflicting setting. – ZzAntáres Feb 10 '18 at 20:47
  • You can try the usual recursive bisection method for debugging: stackoverflow.com/a/23772957/3084001. – Basil Feb 10 '18 at 21:17
  • magit-after-revert-hook and magit-not-reverted-hook no longer exist. Also I recommend you use diff-hl instead of git-gutter. – tarsius Feb 10 '18 at 22:00
  • Thank you! I found the conflicting setting, is this: (add-hook 'font-lock-mode-hook 'hc-highlight-tabs) which I use to see the tabs on files. Is there a workaround so this config can coexist with magit? – ZzAntáres Feb 12 '18 at 3:39
0

Magit and Font-Lock are not compatible.

When Magit inserts text into a buffer it takes care of setting the face property (and others).

Font-Lock on the other hand takes a buffer that already contains all the text and then determines which parts of the buffer need to be propertized (~= colorized). This does not only set the face property (and others) for text that does not have that set yet but for which a rule says that it should, it also removes the existing face property from text that has it set, if there is no rule that says that that should be so.

As a result Font-Lock removes all the text properties that Magit put in place. Font-Lock is most suitable for buffers that visit files. It is not suitable for packages/modes like Dired, Custom, and Magit.


Something is enabling Font-Lock in Magit buffers, but it is not (add-hook 'font-lock-mode-hook 'hc-highlight-tabs) alone. That only says to call hc-highlight-tabs when font-lock-mode is enabled in a buffer anyway. It is however possible that the package that defines hc-highlight-tabs (what package is that?), makes the mistake of enabling font-lock-mode in Magit buffers.

Something similar happens if you enable global-whitespace-mode without setting whitespace-modes to exclude the various Magit modes.


Magit itself provides some support for highlighting certain whitespace in diffs. These features can be activated in the Custom group magit-diff. You probably want magit-diff-highlight-indentation.

  • Thank you, the package that provides that function is highlight-chars.el, I didn't see a way to exclude modes, so I've only enabled it in go-mode which is one of the main modes where I want this feature. – ZzAntáres Feb 14 '18 at 17:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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