changeset 69127:a7ce66a8df73

(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].
author Juri Linkov <juri@jurta.org>
date Thu, 23 Feb 2006 21:41:26 +0000
parents 0a4cb581dcfa
children ab159a9e1d0a
files lisp/compare-w.el
diffstat 1 files changed, 21 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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)))