[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: compare-windows - synchronize points

From: Juri Linkov
Subject: Re: compare-windows - synchronize points
Date: 13 Aug 2003 05:57:36 +0300
User-agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/21.3 (gnu/linux)

Richard Stallman <address@hidden> writes:
> Doing this automatically would be a nice feature, but I wonder
> if that method really does the right job frequently.  Could you tell
> us what kinds of text you have used the feature on, and what values
> you have used, and what sort of results you got?

The most useful result it gives when I compare the different program
outputs which look like this:


and another output which has differences in some fields, e.g.:


The suitable value for compare-windows-sync in this case is the string
containing the field separator ":".  Another good value with the
equivalent result is the function `forward-word'.

I've used it also on human-language texts with differences in some
words and with the value of compare-windows-sync set to `forward-sentence',
and on Lisp programs with the value set to 'end-of-defun'.

The main thing is that the difference region (i.e. region between
current unmatched point and next matching point) should be small
enough for user to fully review it before syncing to the next
matching point.  So generally speaking, this method does the right
job on texts with small differences.

> Could we possibly find good defaults to put in, so that this feature
> can be available by default and won't need customization in order
> to work?

It's difficult to find a common default for all cases.  Seems, the value
of compare-windows-sync should be set by user individually in each case
depending on the nature of texts and differences.  The only general
default value could be a function discussed below.

> Another idea I have for syncing up is that a program could use a
> simple quadratic algorithm to find the first matching 4-character
> string in the two buffers, and move there.  This might get painfully
> slow when there are substantial insertions, though.

I also have thought about implementing a difference algorithm, for
example, such as used in the diff program.  But even such a big Emacs
package as Ediff don't even try to implement a difference algorithms
and fully relies on calling the external diff program.  However, doing
the same thing in compare-windows would be definitely overkill.

Anyhow, this patch could be applied now, since it is already useful enough.
And later, if somebody will implement a good and fast function with a
simple algorithm for finding next matching text, then this function
could be added to compare-w.el and used as the default value for

> The variable should be called compare-windows-sync-function, I think.

Currently the variable compare-windows-sync has no -function suffix,
because it can hold whether a function or a regexp.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]