diff options
| author | Richard M. Stallman | 2006-08-16 05:04:16 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2006-08-16 05:04:16 +0000 |
| commit | 27f9dfbf21276dab85c3a2ff229d3188af8bf0e3 (patch) | |
| tree | df078cd8c119c677dd7fdf54829d0a4997749c09 | |
| parent | 7b245e6346d1759266bf22528d02fd6dc1b0be70 (diff) | |
| download | emacs-27f9dfbf21276dab85c3a2ff229d3188af8bf0e3.tar.gz emacs-27f9dfbf21276dab85c3a2ff229d3188af8bf0e3.zip | |
(compare-windows): Factor compare-ignore-whitespace into ignore-whitespace.
Check each buffer for its skip-function.
Handle compare-windows-skip-whitespace special-case test
by returning t from default skip function.
| -rw-r--r-- | lisp/compare-w.el | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/lisp/compare-w.el b/lisp/compare-w.el index e61f24a0c7c..3aa01424fb5 100644 --- a/lisp/compare-w.el +++ b/lisp/compare-w.el | |||
| @@ -167,16 +167,14 @@ on first call it advances points to the next difference, | |||
| 167 | on second call it synchronizes points by skipping the difference, | 167 | on second call it synchronizes points by skipping the difference, |
| 168 | on third call it again advances points to the next difference and so on." | 168 | on third call it again advances points to the next difference and so on." |
| 169 | (interactive "P") | 169 | (interactive "P") |
| 170 | (if compare-ignore-whitespace | ||
| 171 | (setq ignore-whitespace (not ignore-whitespace))) | ||
| 170 | (let* (p1 p2 maxp1 maxp2 b1 b2 w2 | 172 | (let* (p1 p2 maxp1 maxp2 b1 b2 w2 |
| 171 | (progress 1) | 173 | (progress 1) |
| 172 | (opoint1 (point)) | 174 | (opoint1 (point)) |
| 173 | opoint2 | 175 | opoint2 |
| 174 | (skip-func (if (if ignore-whitespace ; XOR | 176 | skip-func-1 |
| 175 | (not compare-ignore-whitespace) | 177 | skip-func-2 |
| 176 | compare-ignore-whitespace) | ||
| 177 | (if (stringp compare-windows-whitespace) | ||
| 178 | 'compare-windows-skip-whitespace | ||
| 179 | compare-windows-whitespace))) | ||
| 180 | (sync-func (if (stringp compare-windows-sync) | 178 | (sync-func (if (stringp compare-windows-sync) |
| 181 | 'compare-windows-sync-regexp | 179 | 'compare-windows-sync-regexp |
| 182 | compare-windows-sync))) | 180 | compare-windows-sync))) |
| @@ -190,8 +188,19 @@ on third call it again advances points to the next difference and so on." | |||
| 190 | b2 (window-buffer w2)) | 188 | b2 (window-buffer w2)) |
| 191 | (setq opoint2 p2) | 189 | (setq opoint2 p2) |
| 192 | (setq maxp1 (point-max)) | 190 | (setq maxp1 (point-max)) |
| 193 | (save-excursion | 191 | |
| 194 | (set-buffer b2) | 192 | (setq skip-func-1 (if ignore-whitespace |
| 193 | (if (stringp compare-windows-whitespace) | ||
| 194 | (lambda () (compare-windows-skip-whitespace) | ||
| 195 | t) | ||
| 196 | compare-windows-whitespace))) | ||
| 197 | |||
| 198 | (with-current-buffer b2 | ||
| 199 | (setq skip-func-2 (if ignore-whitespace | ||
| 200 | (if (stringp compare-windows-whitespace) | ||
| 201 | (lambda () (compare-windows-skip-whitespace) | ||
| 202 | t) | ||
| 203 | compare-windows-whitespace))) | ||
| 195 | (push-mark p2 t) | 204 | (push-mark p2 t) |
| 196 | (setq maxp2 (point-max))) | 205 | (setq maxp2 (point-max))) |
| 197 | (push-mark) | 206 | (push-mark) |
| @@ -199,17 +208,16 @@ on third call it again advances points to the next difference and so on." | |||
| 199 | (while (> progress 0) | 208 | (while (> progress 0) |
| 200 | ;; If both windows have whitespace next to point, | 209 | ;; If both windows have whitespace next to point, |
| 201 | ;; optionally skip over it. | 210 | ;; optionally skip over it. |
| 202 | (and skip-func | 211 | (and skip-func-1 |
| 203 | (save-excursion | 212 | (save-excursion |
| 204 | (let (p1a p2a w1 w2 result1 result2) | 213 | (let (p1a p2a w1 w2 result1 result2) |
| 205 | (setq result1 (funcall skip-func opoint1)) | 214 | (setq result1 (funcall skip-func-1 opoint1)) |
| 206 | (setq p1a (point)) | 215 | (setq p1a (point)) |
| 207 | (set-buffer b2) | 216 | (set-buffer b2) |
| 208 | (goto-char p2) | 217 | (goto-char p2) |
| 209 | (setq result2 (funcall skip-func opoint2)) | 218 | (setq result2 (funcall skip-func-2 opoint2)) |
| 210 | (setq p2a (point)) | 219 | (setq p2a (point)) |
| 211 | (if (or (stringp compare-windows-whitespace) | 220 | (if (and result1 result2 (eq result1 result2)) |
| 212 | (and result1 result2 (eq result1 result2))) | ||
| 213 | (setq p1 p1a | 221 | (setq p1 p1a |
| 214 | p2 p2a))))) | 222 | p2 p2a))))) |
| 215 | 223 | ||