From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: compare-windows - synchronize points Date: 13 Aug 2003 05:57:36 +0300 Organization: JURTA Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <87oeyuuuvz.fsf@mail.jurta.org> References: <87adagx8x8.fsf@mail.jurta.org> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1060744077 11227 80.91.224.253 (13 Aug 2003 03:07:57 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 13 Aug 2003 03:07:57 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Wed Aug 13 05:07:55 2003 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19mlzP-0005mD-00 for ; Wed, 13 Aug 2003 05:07:55 +0200 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 19mm7O-00034X-00 for ; Wed, 13 Aug 2003 05:16:10 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.20) id 19mlz8-0005Lh-M7 for emacs-devel@quimby.gnus.org; Tue, 12 Aug 2003 23:07:38 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.20) id 19mlxu-0004QJ-94 for emacs-devel@gnu.org; Tue, 12 Aug 2003 23:06:22 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.20) id 19mlxN-0003LY-4D for emacs-devel@gnu.org; Tue, 12 Aug 2003 23:06:20 -0400 Original-Received: from [64.246.52.22] (helo=ns5.tangramltd.com) by monty-python.gnu.org with esmtp (Exim 4.20) id 19mlty-00007A-O8; Tue, 12 Aug 2003 23:02:18 -0400 Original-Received: from 80-235-40-162-dsl.mus.estpak.ee ([80.235.40.162] helo=mail.jurta.org) by ns5.tangramltd.com with esmtp (Exim 4.20) id 19mltr-00048c-Jf; Wed, 13 Aug 2003 06:02:12 +0300 Original-To: rms@gnu.org In-Reply-To: User-agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/21.3 (gnu/linux) Original-Lines: 64 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - ns5.tangramltd.com X-AntiAbuse: Original Domain - gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - jurta.org X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Emacs development discussions. List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:15917 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:15917 Richard Stallman 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/