emacs magit diff highlighting
Asked Answered
M

5

14

I'm just getting started with magit. I really like it, except that the diff viewer is really annoying to me. The chunk highlighting makes no sense because as I scroll around the cursor moves with the screen, highlighting new regions. There is also no other syntax highlighting in the magit diff mode. Does anybody know how to disable the chunk highlighting and get better diff colours other than white on gray?

Thanks.

Mitsukomitt answered 11/5, 2011 at 14:32 Comment(0)
S
4

There should be a customize group magit which allows you to customize all the different faces for the diff viewer.

In other words, you can run

M-x customize-group RET magit-faces RET

to see a list of all the faces used by Magit. The ones relevant to the diff viewer are, of course, the ones starting with Magit Diff.

Simply customize away and select Apply and Save. Alternatively, you can just use the Customize interface to see what faces are available, and then set them directly using set-face-foreground, set-face-background, and so on in your init-file.

Sideway answered 14/5, 2011 at 20:54 Comment(1)
Some details here would be niceKopje
S
13

This is an issue with Magit in combination with Emacs standard theme "wombat".

To work around this, do

M-x customize

Search for magit-item-highlight, click Show All Attributes, uncheck Inherit, then Save and Apply (or maybe only apply).

You lose the highlighting of the current hunk of the diff, but you can tell that still from the hunk's heading anyway, so it was somewhat redundant. Otherwise it resolves the issue nicely.

Sounding answered 15/5, 2013 at 9:37 Comment(2)
This way I also lose highlighting in places where it seems to be useful, for example in logs...Cedillo
Very useful description on how to customize. Helped me as emacs newbie.Camiecamila
K
6

The zone highlighted correspond to the stash that would be staged when you hit "s".

Inside the hunk, the diff should be colored. You could test the development version (see https://github.com/magit/magit), and if this doesn't solve your issue, add comment in https://github.com/magit/magit/issues/133 about your configuration and exact problem.

Korrie answered 11/5, 2011 at 15:5 Comment(1)
Didn't know it was supposed to be on by default. Did some digging, and turns out my emacs color theme was getting in the way. Disabled it and it's a bit better. The gray highlighting still washes out the text, but I can deal with that, and probably fix it eventually.Mitsukomitt
S
4

There should be a customize group magit which allows you to customize all the different faces for the diff viewer.

In other words, you can run

M-x customize-group RET magit-faces RET

to see a list of all the faces used by Magit. The ones relevant to the diff viewer are, of course, the ones starting with Magit Diff.

Simply customize away and select Apply and Save. Alternatively, you can just use the Customize interface to see what faces are available, and then set them directly using set-face-foreground, set-face-background, and so on in your init-file.

Sideway answered 14/5, 2011 at 20:54 Comment(1)
Some details here would be niceKopje
H
3

If you're running the latest 1.0 version, you can also navigate to any of the diff chunks, hit the 'e' key to get an ediff presentation of the differences.

Harragan answered 11/5, 2011 at 15:12 Comment(1)
I am running version 1.0. hitting e in the status buffer either says "cannot resolv a hunk" or "cannot resolve <filename>"Mitsukomitt
I
0

If you don't want to try M-x customize for some reason, simply place the following snippet in your init.el

(defun disable-magit-highlight-in-buffer () 
  (face-remap-add-relative 'magit-item-highlight '()))

(add-hook 'magit-status-mode-hook 'disable-magit-highlight-in-buffer)

Source: https://github.com/magit/magit/issues/133

Innuendo answered 24/6, 2015 at 15:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.