]> code.delx.au - gnu-emacs/blobdiff - lisp/compare-w.el
(Abbrevs): A @node line without explicit Prev, Next, and Up links.
[gnu-emacs] / lisp / compare-w.el
index 353c015c8afc479cf63f3a1ab0c1f39bcca4417a..e61f24a0c7ce313566f577bf4e3c54b64e4d5e91 100644 (file)
@@ -1,6 +1,7 @@
 ;;; compare-w.el --- compare text between windows for Emacs
 
-;; Copyright (C) 1986,1989,1993,1997,2003,2004,2005 Free Software Foundation, Inc.
+;; Copyright (C) 1986, 1989, 1993, 1997, 2002, 2003, 2004,
+;;   2005, 2006 Free Software Foundation, Inc.
 
 ;; Maintainer: FSF
 ;; Keywords: convenience files
@@ -19,8 +20,8 @@
 
 ;; You should have received a copy of the GNU General Public License
 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
 
 ;;; Commentary:
 
@@ -56,7 +57,8 @@ whitespace is considered to match, and is skipped."
 (defcustom compare-ignore-whitespace nil
   "*Non-nil means `compare-windows' ignores whitespace."
   :type 'boolean
-  :group 'compare-w)
+  :group 'compare-w
+  :version "22.1")
 
 (defcustom compare-ignore-case nil
   "*Non-nil means `compare-windows' ignores case differences."
@@ -88,7 +90,8 @@ be made buffer-local.
 If the value of this variable is `nil', then function `ding' is
 called to beep or flash the screen when points are mismatched."
   :type '(choice regexp function)
-  :group 'compare-w)
+  :group 'compare-w
+  :version "22.1")
 
 (defcustom compare-windows-sync-string-size 32
   "*Size of string from one window that is searched in second window.
@@ -99,7 +102,8 @@ difference regions more coarse-grained.
 
 The default value 32 is good for the most cases."
   :type 'integer
-  :group 'compare-w)
+  :group 'compare-w
+  :version "22.1")
 
 (defcustom compare-windows-recenter nil
   "*List of two values, each of which is used as argument of
@@ -109,28 +113,31 @@ matching points side-by-side.
 The value `(-1 0)' is useful if windows are split vertically,
 and the value `((4) (4))' for horizontally split windows."
   :type '(list sexp sexp)
-  :group 'compare-w)
+  :group 'compare-w
+  :version "22.1")
 
 (defcustom compare-windows-highlight t
-  "*Non-nil means compare-windows highlights the differences."
-  :type 'boolean
-  :group 'compare-w)
+  "*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")
 
 (defface compare-windows
-  '((((class color) (min-colors 88) (background light))
-     (:background "paleturquoise"))
-    (((class color) (min-colors 88) (background dark))
-     (:background "paleturquoise4"))
-    (((class color))
-     (:background "turquoise3"))
-    (t (:underline t)))
+  '((t :inherit lazy-highlight))
   "Face for highlighting of compare-windows difference regions."
-  :group 'compare-w)
-;; backward-compatibility alias
-(put 'compare-windows-face 'face-alias 'compare-windows)
+  :group 'compare-w
+  :version "22.1")
 
 (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
@@ -344,21 +351,30 @@ on third call it again advances points to the next difference and so on."
         (move-overlay compare-windows-overlay1 beg1 end1 b1)
       (setq compare-windows-overlay1 (make-overlay beg1 end1 b1))
       (overlay-put compare-windows-overlay1 'face 'compare-windows)
-      (overlay-put compare-windows-overlay1 'priority 1))
+      (overlay-put compare-windows-overlay1 'priority 1000))
     (overlay-put compare-windows-overlay1 'window w1)
     (if compare-windows-overlay2
         (move-overlay compare-windows-overlay2 beg2 end2 b2)
       (setq compare-windows-overlay2 (make-overlay beg2 end2 b2))
       (overlay-put compare-windows-overlay2 'face 'compare-windows)
-      (overlay-put compare-windows-overlay2 'priority 1))
+      (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)))