Implement M-x compare-windows.
authorChris Hanson <org/chris-hanson/cph>
Fri, 11 Oct 1991 03:33:27 +0000 (03:33 +0000)
committerChris Hanson <org/chris-hanson/cph>
Fri, 11 Oct 1991 03:33:27 +0000 (03:33 +0000)
v7/src/edwin/wincom.scm

index f4fc699fb92a8d2797a8bef9084fce007d8bb986..e387deb4adb6720f47b738b2c84eec2eaee98791 100644 (file)
@@ -1,6 +1,6 @@
 ;;; -*-Scheme-*-
 ;;;
-;;;    $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/edwin/wincom.scm,v 1.107 1991/08/23 00:23:45 arthur Exp $
+;;;    $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/edwin/wincom.scm,v 1.108 1991/10/11 03:33:27 cph Exp $
 ;;;
 ;;;    Copyright (c) 1987, 1989-91 Massachusetts Institute of Technology
 ;;;
@@ -597,4 +597,32 @@ Otherwise, the argument is the number of columns desired."
                             (editor-error "restriction too small: " argument))
                         (min x-size argument)))))
              (screen-y-size screen)))
-      (update-screen! screen true))))
\ No newline at end of file
+      (update-screen! screen true))))
+
+(define-command compare-windows
+  "Compare text in current window with text in next window.
+Compares the text starting at point in each window,
+moving over text in each one as far as they match."
+  ()
+  (lambda ()
+    (let ((w1 (current-window))
+         (w2 (other-window-interactive 1)))
+      (let ((p1 (window-point w1)))
+       (let loop ((s1 p1) (s2 (window-point w2)) (length 1024))
+         (if (> length 0)
+             (let ((e1 (mark+ s1 length false))
+                   (e2 (mark+ s2 length false)))
+               (if (and e1
+                        e2
+                        (if (= length 1)
+                            (char=? (extract-right-char s1)
+                                    (extract-right-char s2))
+                            (string=? (extract-string s1 e1)
+                                      (extract-string s2 e2))))
+                   (loop e1 e2 length)
+                   (loop s1 s2 (quotient length 2))))
+             (begin
+               (set-window-point! w1 s1)
+               (set-window-point! w2 s2)
+               (if (mark= s1 p1)
+                   (editor-beep)))))))))
\ No newline at end of file