Next: , Previous: , Up: Customization   [Contents][Index]

7.4 Selective Browsing

Sometimes it is convenient to be able to step through only some difference regions, those that match certain regular expressions, and to ignore all others. On other occasions, you may want to ignore difference regions that match some regular expressions, and to look only at the rest.

The commands #f and #h let you do precisely this.

Typing #f lets you specify regular expressions that match difference regions you want to focus on. We shall call these regular expressions regexp-A, regexp-B and regexp-C. Ediff will then start stepping through only those difference regions where the region in buffer A matches regexp-A and/or the region in buffer B matches regexp-B, etc. Whether “and” or “or” will be used depends on how you respond to a question.

When scanning difference regions for the aforesaid regular expressions, Ediff narrows the buffers to those regions. This means that you can use the expressions \` and \' to tie search to the beginning or end of the difference regions.

On the other hand, typing #h lets you specify (hide) uninteresting regions. That is, if a difference region in buffer A matches regexp-A, the corresponding region in buffer B matches regexp-B and (if applicable) buffer C’s region matches regexp-C, then the region will be ignored by the commands n/SPC (ediff-next-difference) and p/DEL (ediff-previous-difference) commands.

Typing #f and #h toggles selective browsing on and off.

Note that selective browsing affects only ediff-next-difference and ediff-previous-difference, i.e., the commands n/SPC and p/DEL. #f and #h do not change the position of the point in the buffers. And you can still jump directly (using j) to any numbered difference.

Users can supply their own functions to specify how Ediff should do selective browsing. To change the default Ediff function, use something like the following:

(with-eval-after-load 'ediff
  (setq ediff-hide-regexp-matches-function 'your-hide-function)
  (setq ediff-focus-on-regexp-matches-function 'your-focus-function))

Useful hint: To specify a regexp that matches everything, don’t simply type RET in response to a prompt. Typing RET tells Ediff to accept the default value, which may not be what you want. Instead, you should enter something like ^ or $. These match every line.

You can use the status command, i, to find out whether selective browsing is currently in effect.

The regular expressions you specified are kept in the local variables ediff-regexp-focus-A, ediff-regexp-focus-B, ediff-regexp-focus-C, ediff-regexp-hide-A, ediff-regexp-hide-B, ediff-regexp-hide-C. Their default value is the empty string (i.e., nothing is hidden or focused on). To change the default, set these variables in .emacs using setq-default.

In addition to the ability to ignore regions that match regular expressions, Ediff can be ordered to start skipping over certain “uninteresting” difference regions. This is controlled by the following variable:


If t, causes Ediff to skip over "uninteresting" difference regions, which are the regions where the variants differ only in the amount of the white space and newlines. This feature can be toggled on/off interactively, via the command ##.

Please note: in order for this feature to work, auto-refining of difference regions must be on, since otherwise Ediff won’t know if there are fine differences between regions. On devices where Emacs can display faces, auto-refining is a default, but it is not turned on by default on text-only terminals. In that case, you must explicitly turn auto-refining on (such as, by typing @).

Reassurance: If many such uninteresting regions appear in a row, Ediff may take a long time to skip over them because it has to compute fine differences of all intermediate regions. This delay does not indicate any problem.

Finally, Ediff can be told to ignore the case of the letters. This behavior can be toggled with #c and it is controlled with three variables: ediff-ignore-case-option, ediff-ignore-case-option3, and ediff-ignore-case.

The variable ediff-ignore-case-option specifies the option to pass to the diff program for comparing two files or buffers. For GNU diff, this option is "-i". The variable ediff-ignore-case-option3 specifies the option to pass to the diff3 program in order to make it case-insensitive. GNU diff3 does not have such an option, so when merging or comparing three files with this program, ignoring the letter case is not supported.

The variable ediff-ignore-case controls whether Ediff starts out by ignoring letter case or not. It can be set in .emacs using setq-default.

When case sensitivity is toggled, all difference regions are recomputed.

Next: Highlighting Difference Regions, Previous: Window and Frame Configuration, Up: Customization   [Contents][Index]