comparison lisp/compare-w.el @ 4925:76fb8b35df3f

(compare-windows-skip-whitespace): Return t if there is whitespace before point.
author Richard M. Stallman <rms@gnu.org>
date Sun, 07 Nov 1993 22:19:57 +0000
parents d38c94145afe
children c762abae3964
comparison
equal deleted inserted replaced
4924:fb527936ca61 4925:76fb8b35df3f
132 ;; compare-windows-whitespace is a regexp that matches whitespace. 132 ;; compare-windows-whitespace is a regexp that matches whitespace.
133 ;; Match it at various starting points before the original point 133 ;; Match it at various starting points before the original point
134 ;; and find the latest point at which a match ends. 134 ;; and find the latest point at which a match ends.
135 ;; Don't try starting points before START, though. 135 ;; Don't try starting points before START, though.
136 ;; Value is non-nil if whitespace is found. 136 ;; Value is non-nil if whitespace is found.
137
138 ;; If there is whitespace before point, but none after,
139 ;; then return t, but don't advance point.
137 (defun compare-windows-skip-whitespace (start) 140 (defun compare-windows-skip-whitespace (start)
138 (let ((end (point)) 141 (let ((end (point))
142 (beg (point))
139 (opoint (point))) 143 (opoint (point)))
140 (while (and (looking-at compare-windows-whitespace) 144 (while (or (and (/= (point) start)
141 (<= end (match-end 0)) 145 ;; Consider at least the char before point,
142 ;; This match goes past END, so advance END. 146 ;; unless it is also before START.
143 (progn (setq end (match-end 0)) 147 (= (point) opoint))
144 (> (point) start))) 148 (and (looking-at compare-windows-whitespace)
149 (<= end (match-end 0))
150 ;; This match goes past END, so advance END.
151 (progn (setq end (match-end 0))
152 (> (point) start))))
145 ;; keep going back until whitespace 153 ;; keep going back until whitespace
146 ;; doesn't extend to or past end 154 ;; doesn't extend to or past end
147 (forward-char -1)) 155 (forward-char -1))
156 (setq beg (point))
148 (goto-char end) 157 (goto-char end)
149 (/= end opoint))) 158 (or (/= beg opoint)
159 (/= end opoint))))
150 160
151 (provide 'compare-w) 161 (provide 'compare-w)
152 162
153 ;;; compare-w.el ends here 163 ;;; compare-w.el ends here