unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@jurta.org>
Cc: emacs-devel@gnu.org
Subject: Re: compare-windows - synchronize points
Date: 13 Aug 2003 05:57:36 +0300	[thread overview]
Message-ID: <87oeyuuuvz.fsf@mail.jurta.org> (raw)
In-Reply-To: <E19miT6-0004CK-Oy@fencepost.gnu.org>

Richard Stallman <rms@gnu.org> 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:

word1:word2:word3:word4:word5:word6:word7:word8:word9
word1:word2:word3:word4:word5:word6:word7:word8:word9

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

word1:word2:word3:word14:word15:word6:word7:word8:word9
word1:word2:word3:word24:word25:word6:word7:word8:word9

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
compare-windows-sync.

> 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.

-- 
http://www.jurta.org/emacs/

  reply	other threads:[~2003-08-13  2:57 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-08-11 19:59 compare-windows - synchronize points Juri Linkov
2003-08-12 23:22 ` Richard Stallman
2003-08-13  2:57   ` Juri Linkov [this message]
2003-08-14  3:07     ` Richard Stallman
2003-08-14  5:33       ` Juri Linkov
2003-08-16 16:19         ` Richard Stallman
2003-08-18 21:35           ` Juri Linkov
2003-08-20  2:43             ` Richard Stallman
2003-08-20  5:56               ` Juri Linkov
2003-08-26  1:38                 ` Richard Stallman
2003-08-26  5:28                   ` Juri Linkov
2003-08-27 16:42                     ` Richard Stallman
2003-08-14 10:43     ` Alex Schroeder
2003-08-14 14:43       ` Juri Linkov
2003-08-14 23:59         ` Alex Schroeder
2003-08-15  4:21           ` Juri Linkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87oeyuuuvz.fsf@mail.jurta.org \
    --to=juri@jurta.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).