summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>1993-07-13 07:31:09 +0000
committerRichard M. Stallman <rms@gnu.org>1993-07-13 07:31:09 +0000
commit14b2d9c106b7f74117f4c2b89cf331b6c7d76a45 (patch)
tree2eb8ff7997d8c7fc3fa093f73bbb08d94cadee02
parent18834c8b3433793ea20ca86946e534eecf65473e (diff)
downloademacs-14b2d9c106b7f74117f4c2b89cf331b6c7d76a45.tar.gz
(compare-windows-skip-whitespace): New function.
(compare-windows): Use that. (compare-windows-whitespace): Value is now regexp.
-rw-r--r--lisp/compare-w.el55
1 files changed, 34 insertions, 21 deletions
diff --git a/lisp/compare-w.el b/lisp/compare-w.el
index b7df1ad31b4..a52e8e07541 100644
--- a/lisp/compare-w.el
+++ b/lisp/compare-w.el
@@ -1,6 +1,6 @@
;;; compare-w.el --- compare text between windows for Emacs.
-;; Copyright (C) 1986, 1989 Free Software Foundation, Inc.
+;; Copyright (C) 1986, 1989, 1993 Free Software Foundation, Inc.
;; Maintainer: FSF
@@ -29,8 +29,8 @@
;;; Code:
-(defvar compare-windows-whitespace " \t\n"
- "*String of characters considered whitespace for \\[compare-windows].
+(defvar compare-windows-whitespace "[ \t\n]+"
+ "*Regexp that defines whitespace sequences for \\[compare-windows].
Changes in whitespace are optionally ignored.
The value of `compare-windows-whitespace' may instead be a function; this
@@ -61,8 +61,7 @@ If `compare-ignore-case' is non-nil, changes in case are also ignored."
(opoint1 (point))
opoint2
(skip-whitespace (if ignore-whitespace
- compare-windows-whitespace))
- (skip-whitespace-regexp (concat "[" skip-whitespace "]+")))
+ compare-windows-whitespace)))
(setq p1 (point) b1 (current-buffer))
(setq w2 (next-window (selected-window)))
(if (eq w2 (selected-window))
@@ -88,24 +87,18 @@ If `compare-ignore-case' is non-nil, changes in case are also ignored."
(and skip-whitespace
(save-excursion
(let (p1a p2a w1 w2 result1 result2)
- (if (stringp skip-whitespace)
- (progn
- (if (not (eobp))
- (skip-chars-backward skip-whitespace opoint1))
- (and (looking-at skip-whitespace-regexp)
- (setq p1a (match-end 0) result1 t)))
- (setq result1 (funcall skip-whitespace opoint1))
- (setq p1a (point)))
+ (setq result1
+ (if (stringp skip-whitespace)
+ (compare-windows-skip-whitespace opoint1)
+ (funcall skip-whitespace opoint1)))
+ (setq p1a (point))
(set-buffer b2)
(goto-char p2)
- (if (stringp skip-whitespace)
- (progn
- (if (not (eobp))
- (skip-chars-backward skip-whitespace opoint2))
- (and (looking-at skip-whitespace-regexp)
- (setq p2a (match-end 0) result2 t)))
- (setq result2 (funcall skip-whitespace opoint2))
- (setq p2a (point)))
+ (setq result2
+ (if (stringp skip-whitespace)
+ (compare-windows-skip-whitespace opoint2)
+ (funcall skip-whitespace opoint2)))
+ (setq p2a (point))
(and result1 result2 (eq result1 result2)
(setq p1 p1a
p2 p2a)))))
@@ -135,6 +128,26 @@ If `compare-ignore-case' is non-nil, changes in case are also ignored."
(if (= (point) opoint1)
(ding))))
+;; Move forward over whatever might be called whitespace.
+;; compare-windows-whitespace is a regexp that matches whitespace.
+;; Match it at various starting points before the original point
+;; and find the latest point at which a match ends.
+;; Don't try starting points before START, though.
+;; Value is non-nil if whitespace is found.
+(defun compare-windows-skip-whitespace (start)
+ (let ((end (point))
+ (opoint (point)))
+ (while (and (looking-at compare-windows-whitespace)
+ (<= end (match-end 0))
+ ;; This match goes past END, so advance END.
+ (progn (setq end (match-end 0))
+ (> (point) start)))
+ ;; keep going back until whitespace
+ ;; doesn't extend to or past end
+ (forward-char -1))
+ (goto-char end)
+ (/= end opoint)))
+
(provide 'compare-w)
;;; compare-w.el ends here