Search code examples
gitemacshighlightmagit

Magit: how to disable highlight in the selected diff hunk


I'm using emacs 27.2 and magit 20210406.454. When I show a diff on magit (i.g., on magit-diff) the selected whole hunk is highlighted. How can I disable it?

For example, this is the screen capture when I show the diff on magit:

Not selected hunk

It shows added lines in green and removed lines in red, which is good. However when I move the cursor to the first hunk, the color of added lines is changed to blue:

Selected the first hunk

The current line is highlighted in yellow. Also, when I move the cursor to the next hunk that has both added lines and removed lines, the color of those lines are changed:

Enter image description here

What I'd like to do is to disable highlighting only on added lines and removed lines (i.e., keeping showing those lines in greed and red) while keeping showing the current line in yellow. Is that possible?


Solution

  • You'll be able to edit the relevant faces from here:

    M-x customize-group RET magit-faces RET

    You'll likely spot them based on the displayed examples in that buffer.

    Also note that magit may defer to diff-mode faces for some things, so it might also be useful to look at:

    M-x customize-group RET diff-mode RET

    I think the faces you're looking for will be:

    • magit-diff-added-highlight
    • magit-diff-removed-highlight

    In addition you may or may not care about:

    • magit-diff-base-highlight
    • magit-diff-context-highlight
    • magit-diff-file-heading-highlight
    • magit-diff-hunk-heading-highlight
    • magit-diff-our-highlight
    • magit-diff-their-highlight

    For the ones you don't want to vary contextually, you can make the face inherit from the equivalent non-highlight face.