;;; compare-w.el --- compare text between windows for Emacs
-;; Copyright (C) 1986,1989,1993,1997,2003,2004 Free Software Foundation, Inc.
+;; Copyright (C) 1986, 1989, 1993, 1997, 2002, 2003, 2004,
+;; 2005 Free Software Foundation, Inc.
;; Maintainer: FSF
;; Keywords: convenience files
;; 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:
(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."
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.
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
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)
+ :group 'compare-w
+ :version "22.1")
-(defface compare-windows-face
- '((((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)))
+(defface compare-windows
+ '((t :inherit lazy-highlight))
"Face for highlighting of compare-windows difference regions."
- :group 'compare-w)
+ :group 'compare-w
+ :version "22.1")
(defvar compare-windows-overlay1 nil)
(defvar compare-windows-overlay2 nil)
;; to be used when this function is called on second window.
(defun compare-windows-sync-default-function ()
(if (not compare-windows-sync-point)
- (let* ((w2 (next-window (selected-window)))
+ (let* ((w1 (selected-window))
+ (w2 (next-window w1))
(b2 (window-buffer w2))
(point-max2 (with-current-buffer b2 (point-max)))
(op2 (window-point w2))
;; use closest matching points (i.e. points with minimal sum)
(setq p12 (cdr (assq (apply 'min (mapcar 'car p12s)) p12s)))
(goto-char (car p12))
- (compare-windows-highlight op1 (car p12) op2 (cadr p12) b2))
+ (compare-windows-highlight op1 (car p12) (current-buffer) w1
+ op2 (cadr p12) b2 w2))
(setq compare-windows-sync-point (or (cadr p12) t)))
;; else set point in the second window to the pre-calculated value
(if (numberp compare-windows-sync-point)
(setq compare-windows-sync-point nil)))
;; Highlight differences
-(defun compare-windows-highlight (beg1 end1 beg2 end2 buf2)
+(defun compare-windows-highlight (beg1 end1 b1 w1 beg2 end2 b2 w2)
(when compare-windows-highlight
(if compare-windows-overlay1
- (move-overlay compare-windows-overlay1 beg1 end1 (current-buffer))
- (setq compare-windows-overlay1 (make-overlay beg1 end1 (current-buffer)))
- (overlay-put compare-windows-overlay1 'face 'compare-windows-face)
+ (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 'window w1)
(if compare-windows-overlay2
- (move-overlay compare-windows-overlay2 beg2 end2 buf2)
- (setq compare-windows-overlay2 (make-overlay beg2 end2 buf2))
- (overlay-put compare-windows-overlay2 'face 'compare-windows-face)
+ (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 'window w2)
;; Remove highlighting before next command is executed
(add-hook 'pre-command-hook 'compare-windows-dehighlight)))