From 7c1037cb31d697ed4d47edcd71cdae2df9773430 Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Fri, 11 Oct 1991 03:33:27 +0000 Subject: [PATCH] Implement M-x compare-windows. --- v7/src/edwin/wincom.scm | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/v7/src/edwin/wincom.scm b/v7/src/edwin/wincom.scm index f4fc699fb..e387deb4a 100644 --- a/v7/src/edwin/wincom.scm +++ b/v7/src/edwin/wincom.scm @@ -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 -- 2.25.1