Lugaru's Epsilon Programmer's Editor 14b12
Context:
|
Epsilon User's Manual and Reference > Commands by Topic > Moving Around > Comparing Two BuffersThe compare-windows command on Ctrl-F2 finds differences between the contents of the current buffer and that displayed in the next window on the screen. If called while in the last window, it compares that window with the first window. The comparison begins at point in each window. Epsilon finds the first difference between the buffers and moves the point to just before the differing characters, or to the ends of the buffers if it finds no difference. It then displays a message in the echo area reporting whether or not it found a difference.If you invoke compare-windows again immediately after it has found a difference, the command will try to resynchronize the windows by moving forward in each window until it finds a match of at least resynch-match-chars characters. It doesn't necessarily move each window by the same amount, but instead finds a match that minimizes the movement in the window that it moves the most. It then reports the number of characters in each window it skipped past. Normally compare-windows treats one run of space and tab characters the same as any other run, so it skips over differences in horizontal whitespace. You can set the compare-windows-ignores-space variable to change this. The diff command also compares the buffers in two windows, but it will compare and resynchronize over and over from the beginning to the end of each buffer, producing a report that lists all differences between the two buffers. It operates line-by-line rather than character-by-character. When resynchronizing, diff believes it has found another match when diff-match-lines lines in a row match, and gives up if it cannot find a match within diff-mismatch-lines lines. By default, diff resynchronizes when it encounters three lines in a row that match. Normally Epsilon uses a smarter algorithm that's better at finding a minimum set of differences. With this algorithm, diff-mismatch-lines isn't used. But because this algorithm becomes very slow when buffers are large, it's only used when at least one of the buffers contains fewer than diff-precise-limit bytes (by default 4 MB). The diff command reports each difference with a summary line and then the text of the differing lines. The summary line consists of two line number ranges with a letter between them indicating the type of change: "a" indicates lines to add to the first buffer to match the second, "d" indicates lines to delete, and "c" indicates lines to change. For example, a summary line in the diff listing of "20,30c23,29" means to remove lines 20 through 30 from the first buffer and replace them with a copy of lines 23 through 29 from the second buffer. "11a12" means that adding line 12 from the second buffer right after line 11 in the first buffer would make them identical. "11,13d10" means that deleting lines 11, 12 and 13 from the first buffer (which would appear just after line 10 in the second) would make them identical.
After each summary line, diff puts the lines to which the
summary refers. The diff command prefixes lines to delete
from the first buffer by " The visual-diff command is like diff but uses colors to show differences. It constructs a new buffer that contains all the lines of the two buffers. Lines from the first buffer that don't appear in the second are displayed with a red background. Lines in the second buffer that don't appear in the first have a yellow background. Lines that are the same in both buffers are colored normally. This command also does character-by-character highlighting for each group of changed lines. Instead of simply indicating that one group of lines was replaced by another, it shows which portions of the lines changed and which did not, by omitting the red or yellow background from those characters. You can set the variables diff-match-characters and diff-match-characters-limit to alter or turn off this behavior. In a visual-diff buffer, the keys Alt-<Down> and Alt-] move to the start of the next changed or common section. The keys Alt-<Up> and Alt-[ move to the previous change or common section. These keys work in diff buffers too, moving to the next or previous block of differences. In both visual-diff and diff buffers, you can press "a" or "b" to visit either of the two files being compared. Press "c" to visit both in a pair of windows, one below the other, or "s" to visit both in side-by-side windows. Press Shift-A to copy file A to file B, or Shift-B to copy file B to file A. You will be prompted to confirm overwriting the existing file. Overwriting a newer file with an older one will mention that in the prompt. The merge-diff command is another variation on diff that's useful with buffers in C mode. It marks differences by surrounding them with #ifdef preprocessor lines, first prompting for the #ifdef variable name to use. The resulting buffer receives the mode and settings of the first of the original buffers. The marking is mechanical, and doesn't parse the text being marked off, so it may produce invalid code. For example, if an #if statement differs between the two buffers, the result will contain improperly nested #if statements like this:
The commands diff, visual-diff, and merge-diff
all produce their output in a buffer named The compare-to-prior-version command uses visual-diff to show the differences between the current version of a buffer and the one saved on disk. It can also compare the current version with the version prior to a certain number of editing operations. It prompts for the number of editing operations; entering zero makes it compare the current buffer to the version of it on disk. The command can display its results using merge-diff or diff instead of visual-diff; see the compare-to-prior-version-style variable.
|