diff options
| author | Juri Linkov | 2004-11-28 07:56:01 +0000 |
|---|---|---|
| committer | Juri Linkov | 2004-11-28 07:56:01 +0000 |
| commit | efbbac291e1acd93446a189e86fd754d6d739f6e (patch) | |
| tree | 517eda50a4c4e68e1abd3d9667ce8d1e41a7e394 | |
| parent | 9e66b14a65aaf2951e2b4ff763b4cfb7dc3e8d02 (diff) | |
| download | emacs-efbbac291e1acd93446a189e86fd754d6d739f6e.tar.gz emacs-efbbac291e1acd93446a189e86fd754d6d739f6e.zip | |
(compare-windows-highlight): Attach each overlay
to its window to properly highlight differences while comparing
two windows of the same buffer. Fix arguments.
(compare-windows-sync-default-function): Fix arguments of
`compare-windows-highlight'.
| -rw-r--r-- | lisp/compare-w.el | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/lisp/compare-w.el b/lisp/compare-w.el index 7e23c9efedf..c9b26a6eb5b 100644 --- a/lisp/compare-w.el +++ b/lisp/compare-w.el | |||
| @@ -283,7 +283,8 @@ on third call it again advances points to the next difference and so on." | |||
| 283 | ;; to be used when this function is called on second window. | 283 | ;; to be used when this function is called on second window. |
| 284 | (defun compare-windows-sync-default-function () | 284 | (defun compare-windows-sync-default-function () |
| 285 | (if (not compare-windows-sync-point) | 285 | (if (not compare-windows-sync-point) |
| 286 | (let* ((w2 (next-window (selected-window))) | 286 | (let* ((w1 (selected-window)) |
| 287 | (w2 (next-window w1)) | ||
| 287 | (b2 (window-buffer w2)) | 288 | (b2 (window-buffer w2)) |
| 288 | (point-max2 (with-current-buffer b2 (point-max))) | 289 | (point-max2 (with-current-buffer b2 (point-max))) |
| 289 | (op2 (window-point w2)) | 290 | (op2 (window-point w2)) |
| @@ -326,7 +327,8 @@ on third call it again advances points to the next difference and so on." | |||
| 326 | ;; use closest matching points (i.e. points with minimal sum) | 327 | ;; use closest matching points (i.e. points with minimal sum) |
| 327 | (setq p12 (cdr (assq (apply 'min (mapcar 'car p12s)) p12s))) | 328 | (setq p12 (cdr (assq (apply 'min (mapcar 'car p12s)) p12s))) |
| 328 | (goto-char (car p12)) | 329 | (goto-char (car p12)) |
| 329 | (compare-windows-highlight op1 (car p12) op2 (cadr p12) b2)) | 330 | (compare-windows-highlight op1 (car p12) (current-buffer) w1 |
| 331 | op2 (cadr p12) b2 w2)) | ||
| 330 | (setq compare-windows-sync-point (or (cadr p12) t))) | 332 | (setq compare-windows-sync-point (or (cadr p12) t))) |
| 331 | ;; else set point in the second window to the pre-calculated value | 333 | ;; else set point in the second window to the pre-calculated value |
| 332 | (if (numberp compare-windows-sync-point) | 334 | (if (numberp compare-windows-sync-point) |
| @@ -334,18 +336,20 @@ on third call it again advances points to the next difference and so on." | |||
| 334 | (setq compare-windows-sync-point nil))) | 336 | (setq compare-windows-sync-point nil))) |
| 335 | 337 | ||
| 336 | ;; Highlight differences | 338 | ;; Highlight differences |
| 337 | (defun compare-windows-highlight (beg1 end1 beg2 end2 buf2) | 339 | (defun compare-windows-highlight (beg1 end1 b1 w1 beg2 end2 b2 w2) |
| 338 | (when compare-windows-highlight | 340 | (when compare-windows-highlight |
| 339 | (if compare-windows-overlay1 | 341 | (if compare-windows-overlay1 |
| 340 | (move-overlay compare-windows-overlay1 beg1 end1 (current-buffer)) | 342 | (move-overlay compare-windows-overlay1 beg1 end1 b1) |
| 341 | (setq compare-windows-overlay1 (make-overlay beg1 end1 (current-buffer))) | 343 | (setq compare-windows-overlay1 (make-overlay beg1 end1 b1)) |
| 342 | (overlay-put compare-windows-overlay1 'face 'compare-windows-face) | 344 | (overlay-put compare-windows-overlay1 'face 'compare-windows-face) |
| 343 | (overlay-put compare-windows-overlay1 'priority 1)) | 345 | (overlay-put compare-windows-overlay1 'priority 1)) |
| 346 | (overlay-put compare-windows-overlay1 'window w1) | ||
| 344 | (if compare-windows-overlay2 | 347 | (if compare-windows-overlay2 |
| 345 | (move-overlay compare-windows-overlay2 beg2 end2 buf2) | 348 | (move-overlay compare-windows-overlay2 beg2 end2 b2) |
| 346 | (setq compare-windows-overlay2 (make-overlay beg2 end2 buf2)) | 349 | (setq compare-windows-overlay2 (make-overlay beg2 end2 b2)) |
| 347 | (overlay-put compare-windows-overlay2 'face 'compare-windows-face) | 350 | (overlay-put compare-windows-overlay2 'face 'compare-windows-face) |
| 348 | (overlay-put compare-windows-overlay2 'priority 1)) | 351 | (overlay-put compare-windows-overlay2 'priority 1)) |
| 352 | (overlay-put compare-windows-overlay2 'window w2) | ||
| 349 | ;; Remove highlighting before next command is executed | 353 | ;; Remove highlighting before next command is executed |
| 350 | (add-hook 'pre-command-hook 'compare-windows-dehighlight))) | 354 | (add-hook 'pre-command-hook 'compare-windows-dehighlight))) |
| 351 | 355 | ||