# HG changeset patch # User Juri Linkov # Date 1140730886 0 # Node ID a7ce66a8df73cd9fe10f764b97b3d23b19626306 # Parent 0a4cb581dcfad341e4a14b9b01b6d3c8eb55e5e3 (compare-windows-highlight): Add new value `persistent' and change :type from `boolean' to `choice'. (compare-windows-overlays1, compare-windows-overlays2): New internal variables. (compare-windows-highlight): If compare-windows-highlight is `persistent', add current overlays to compare-windows-overlays[12] instead of adding compare-windows-dehighlight to pre-command-hook. (compare-windows-dehighlight): Delete all overlays from compare-windows-overlays[12]. diff -r 0a4cb581dcfa -r a7ce66a8df73 lisp/compare-w.el --- a/lisp/compare-w.el Thu Feb 23 16:39:24 2006 +0000 +++ b/lisp/compare-w.el Thu Feb 23 21:41:26 2006 +0000 @@ -117,8 +117,14 @@ :version "22.1") (defcustom compare-windows-highlight t - "*Non-nil means compare-windows highlights the differences." - :type 'boolean + "*Non-nil means compare-windows highlights the differences. +The value t removes highlighting immediately after invoking a command +other than `compare-windows'. +The value `persistent' leaves all highlighted differences. You can clear +out all highlighting later with the command `compare-windows-dehighlight'." + :type '(choice (const :tag "No highlighting" nil) + (const :tag "Persistent highlighting" persistent) + (other :tag "Highlight until next command" t)) :group 'compare-w :version "22.1") @@ -130,6 +136,8 @@ (defvar compare-windows-overlay1 nil) (defvar compare-windows-overlay2 nil) +(defvar compare-windows-overlays1 nil) +(defvar compare-windows-overlays2 nil) (defvar compare-windows-sync-point nil) ;;;###autoload @@ -351,13 +359,22 @@ (overlay-put compare-windows-overlay2 'face 'compare-windows) (overlay-put compare-windows-overlay2 'priority 1000)) (overlay-put compare-windows-overlay2 'window w2) - ;; Remove highlighting before next command is executed - (add-hook 'pre-command-hook 'compare-windows-dehighlight))) + (if (not (eq compare-windows-highlight 'persistent)) + ;; Remove highlighting before next command is executed + (add-hook 'pre-command-hook 'compare-windows-dehighlight) + (when compare-windows-overlay1 + (push (copy-overlay compare-windows-overlay1) compare-windows-overlays1) + (delete-overlay compare-windows-overlay1)) + (when compare-windows-overlay2 + (push (copy-overlay compare-windows-overlay2) compare-windows-overlays2) + (delete-overlay compare-windows-overlay2))))) (defun compare-windows-dehighlight () "Remove highlighting created by `compare-windows-highlight'." (interactive) (remove-hook 'pre-command-hook 'compare-windows-dehighlight) + (mapc 'delete-overlay compare-windows-overlays1) + (mapc 'delete-overlay compare-windows-overlays2) (and compare-windows-overlay1 (delete-overlay compare-windows-overlay1)) (and compare-windows-overlay2 (delete-overlay compare-windows-overlay2)))