Next: Narrowing, Previous: Selective Browsing, Up: Customization [Contents][Index]

### 7.5 Highlighting Difference Regions

The following variables control the way Ediff highlights difference regions:

`ediff-before-flag-bol`
`ediff-after-flag-eol`
`ediff-before-flag-mol`
`ediff-after-flag-mol`

  These variables hold strings that Ediff uses to mark the beginning and the end of the differences found in files A, B, and C on devices where Emacs cannot display faces. Ediff uses different flags to highlight regions that begin/end at the beginning/end of a line or in a middle of a line.

`ediff-current-diff-face-A`
`ediff-current-diff-face-B`
`ediff-current-diff-face-C`

  Ediff uses these faces to highlight current differences on devices where Emacs can display faces. These and subsequently described faces can be set either in `.emacs` or in `.Xdefaults`. The X resource for Ediff is ‘`Ediff`’, not ‘`emacs`’. Please refer to Emacs manual for the information on how to set X resources.

`ediff-fine-diff-face-A`
`ediff-fine-diff-face-B`
`ediff-fine-diff-face-C`

  Ediff uses these faces to show the fine differences between the current differences regions in buffers A, B, and C, respectively.

`ediff-even-diff-face-A`
`ediff-even-diff-face-B`
`ediff-even-diff-face-C`
`ediff-odd-diff-face-A`
`ediff-odd-diff-face-B`
`ediff-odd-diff-face-C`

  Non-current difference regions are displayed using these alternating faces. The odd and the even faces are actually identical on monochrome displays, because without colors options are limited. So, Ediff uses italics to highlight non-current differences.

`ediff-force-faces`

  Ediff generally can detect when Emacs is running on a device where it can use highlighting with faces. However, if it fails to determine that faces can be used, the user can set this variable to `t` to make sure that Ediff uses faces to highlight differences.

`ediff-highlight-all-diffs`

  Indicates whether—on a windowing display—Ediff should highlight differences using inserted strings (as on text-only terminals) or using colors and highlighting. Normally, Ediff highlights all differences, but the selected difference is highlighted more visibly. One can cycle through various modes of highlighting by typing `h`. By default, Ediff starts in the mode where all difference regions are highlighted. If you prefer to start in the mode where unselected differences are not highlighted, you should set `ediff-highlight-all-diffs` to `nil`. Type `h` to restore highlighting for all differences.

  Ediff lets you switch between the two modes of highlighting. That is, you can switch interactively from highlighting using faces to highlighting using string flags, and back. Of course, switching has effect only under a windowing system. On a text-only terminal or in an xterm window, the only available option is highlighting with strings.

If you want to change the default settings for `ediff-force-faces` and `ediff-highlight-all-diffs`, you must do it before Ediff is loaded.

You can also change the defaults for the faces used to highlight the difference regions. There are two ways to do this. The simplest and the preferred way is to use the customization widget accessible from the menubar. Ediff’s customization group is located under "Tools", which in turn is under "Programming". The faces that are used to highlight difference regions are located in the "Highlighting" subgroup of the Ediff customization group.

The second, much more arcane, method to change default faces is to include some Lisp code in `~/.emacs`. For instance,

    (setq ediff-current-diff-face-A
          (copy-face 'bold-italic 'ediff-current-diff-face-A))

would use the pre-defined face `bold-italic` to highlight the current difference region in buffer A (this face is not a good choice, by the way).

If you are unhappy with just some of the aspects of the default faces, you can modify them when Ediff is being loaded using `ediff-load-hook`. For instance:

    (add-hook 'ediff-load-hook
              (lambda ()
                (set-face-foreground
                  ediff-current-diff-face-B "blue")
                (set-face-background
                  ediff-current-diff-face-B "red")
                (make-face-italic
                  ediff-current-diff-face-B)))

Please note: to set Ediff’s faces, use only `copy-face` or `set/make-face-…` as shown above. Emacs’s low-level face-manipulation functions should be avoided.

Next: Narrowing, Previous: Selective Browsing, Up: Customization [Contents][Index]