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:
Reading such diffs is di开发者_StackOverflowfficult. How do I configure Emacs,
- to highlight
-
and+
lines with different colors? (red and blue, for example) - to highlight word difference (like BitBucket and GitHub do)
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))
精彩评论