开发者

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:

How to configure highlighting in Emacs diff mode?

Reading such diffs is di开发者_StackOverflowfficult. 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)


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))
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜