emacs-pretest-bug
[Top][All Lists]
Advanced

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

Re: compare-windows trouble


From: Devon Sean McCullough
Subject: Re: compare-windows trouble
Date: Thu, 25 Nov 2004 09:07:16 -0500 (EST)

Thank you!  Great work, much better with the patch.

It's still not smart enough to highlight both first lines as different
and then skip over the identical rest of each paragraph, as it would
do if the first para were in a different buffer with nothing after. *

                Peace
                        --Devon
         /~\
         \ /    Health Care
          X     not warfare
         / \

        Kerry won the popular vote
        Dubya won the digital vote

PS: Oh shit, I exposed my real address.  The archive is spam-safe, I hope?

PPS: I bet it would be easy for compare-windows to notice when you
manually skip over a difference and then maybe duplicate your skip
in the other window, e.g., compare-windows, eol, compare-windows
might advance both sides to eol if it could guess what exactly
you were aiming at.  Hmmm, C-u prefix is already kinda DWIM.

One of these days we'll have it learning to skip specified changes,
e.g., a set of name changes.  This would naturally know about
change logs and patches, hoo boy!  Not today, I have a long drive.

----------------
*  But that way lies LAPIS http://www.cs.cmu.edu/rcm/lapis
which I've wanted to add to EMACS for years (LAPIS is in Java,
yeecchh) ever since applauding the author's talk at LCS
http://www-2.cs.cmu.edu/~rcm/papers/chi02/chi02.html
but there's always this little matter of bringing
bread to the table and keeping the roof from
leaking.  Someday.  Maybe in EMACS-TNG
should that ever begin to exist.

From: Juri Linkov <address@hidden>
Subject: Re: compare-windows trouble
Organization: JURTA
Date: Thu, 25 Nov 2004 07:04:15 +0200
In-Reply-To: <address@hidden> (message of "Wed, 24 Nov 2004 20:03:03 -0500 
(EST)")

> The new nicer compare-windows wins comparing separate files
> but loses comparing similar sections of the same buffer.

Thanks for the report.  As I see it can handle comparing two windows
of the same buffer (correctly preserves points in both windows and so on)
except the highlighting problem you reported.  Could you try the patch
below and see if there are any problems with it?

> Does anyone collect regression tests like this?

No, Emacs is too big for regression tests :-)

Index: lisp/compare-w.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/compare-w.el,v
retrieving revision 1.25
diff -u -r1.25 compare-w.el
--- lisp/compare-w.el   20 May 2004 16:41:41 -0000      1.25
+++ lisp/compare-w.el   25 Nov 2004 04:47:59 -0000
@@ -283,7 +283,8 @@
 ;; to be used when this function is called on second window.
 (defun compare-windows-sync-default-function ()
   (if (not compare-windows-sync-point)
-      (let* ((w2 (next-window (selected-window)))
+      (let* ((w1 (selected-window))
+             (w2 (next-window w1))
              (b2 (window-buffer w2))
              (point-max2 (with-current-buffer b2 (point-max)))
              (op2 (window-point w2))
@@ -326,7 +327,8 @@
           ;; use closest matching points (i.e. points with minimal sum)
           (setq p12 (cdr (assq (apply 'min (mapcar 'car p12s)) p12s)))
           (goto-char (car p12))
-          (compare-windows-highlight op1 (car p12) op2 (cadr p12) b2))
+          (compare-windows-highlight op1 (car p12) (current-buffer) w1
+                                     op2 (cadr p12) b2 w2))
         (setq compare-windows-sync-point (or (cadr p12) t)))
     ;; else set point in the second window to the pre-calculated value
     (if (numberp compare-windows-sync-point)
@@ -334,18 +336,20 @@
     (setq compare-windows-sync-point nil)))
 
 ;; Highlight differences
-(defun compare-windows-highlight (beg1 end1 beg2 end2 buf2)
+(defun compare-windows-highlight (beg1 end1 b1 w1 beg2 end2 b2 w2)
   (when compare-windows-highlight
     (if compare-windows-overlay1
-        (move-overlay compare-windows-overlay1 beg1 end1 (current-buffer))
-      (setq compare-windows-overlay1 (make-overlay beg1 end1 (current-buffer)))
+        (move-overlay compare-windows-overlay1 beg1 end1 b1)
+      (setq compare-windows-overlay1 (make-overlay beg1 end1 b1))
       (overlay-put compare-windows-overlay1 'face 'compare-windows-face)
       (overlay-put compare-windows-overlay1 'priority 1))
+    (overlay-put compare-windows-overlay1 'window w1)
     (if compare-windows-overlay2
-        (move-overlay compare-windows-overlay2 beg2 end2 buf2)
-      (setq compare-windows-overlay2 (make-overlay beg2 end2 buf2))
+        (move-overlay compare-windows-overlay2 beg2 end2 b2)
+      (setq compare-windows-overlay2 (make-overlay beg2 end2 b2))
       (overlay-put compare-windows-overlay2 'face 'compare-windows-face)
       (overlay-put compare-windows-overlay2 'priority 1))
+    (overlay-put compare-windows-overlay2 'window w2)
     ;; Remove highlighting before next command is executed
     (add-hook 'pre-command-hook 'compare-windows-dehighlight)))

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





reply via email to

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