comparison lisp/compare-w.el @ 90054:f2ebccfa87d4

Revision: miles@gnu.org--gnu-2004/emacs--unicode--0--patch-74 Merge from emacs--cvs-trunk--0 Patches applied: * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-709 Update from CVS: src/indent.c (Fvertical_motion): Fix last change. * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-710 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-715 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-716 Merge from gnus--rel--5.10 * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-74 Update from CVS
author Miles Bader <miles@gnu.org>
date Wed, 08 Dec 2004 05:02:30 +0000
parents 4c90ffeb71c5 4663989dd34a
children a1b34dec1104
comparison
equal deleted inserted replaced
90053:fff5f1a61d92 90054:f2ebccfa87d4
281 ;; On the first call both matching points are computed, 281 ;; On the first call both matching points are computed,
282 ;; and one of them is stored in compare-windows-sync-point 282 ;; and one of them is stored in compare-windows-sync-point
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))
290 (op1 (point)) 291 (op1 (point))
291 (region-size compare-windows-sync-string-size) 292 (region-size compare-windows-sync-string-size)
324 (setq p1 (1+ p1))))) 325 (setq p1 (1+ p1)))))
325 (when p12s 326 (when p12s
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)
333 (goto-char compare-windows-sync-point)) 335 (goto-char compare-windows-sync-point))
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
352 (defun compare-windows-dehighlight () 356 (defun compare-windows-dehighlight ()
353 "Remove highlighting created by `compare-windows-highlight'." 357 "Remove highlighting created by `compare-windows-highlight'."