Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure highlighting in Emacs diff mode?

I use mercurial.el mode with Emacs. When I run vc-diff, I can see the diff, but, unlike the source code, it is not nicely highlighted:

Emacs vc-diff

Reading such diffs is difficult. How do I configure Emacs,

  1. to highlight - and + lines with different colors? (red and blue, for example)
  2. to highlight word difference (like BitBucket and GitHub do)
like image 379
sastanin Avatar asked Nov 02 '10 16:11

sastanin


1 Answers

Try using M-x ediff-revision, which does an ediff instead of just a regular diff. That will give you word-differences and a side-by-side (or top/bottom) display. Check out the ediff manual.

The Emacs wiki also has a number of modes for just regular diff files (like what you're looking at) - check it out.

To just change the colors in the diff-mode which you're currently using, you can do something like:

(defun update-diff-colors ()
  "update the colors for diff faces"
  (set-face-attribute 'diff-added nil
                      :foreground "white" :background "blue")
  (set-face-attribute 'diff-removed nil
                      :foreground "white" :background "red3")
  (set-face-attribute 'diff-changed nil
                      :foreground "white" :background "purple"))
(eval-after-load "diff-mode"
  '(update-diff-colors))
like image 191
Trey Jackson Avatar answered Nov 15 '22 09:11

Trey Jackson