diff options
| author | Juri Linkov | 2006-02-23 21:41:26 +0000 |
|---|---|---|
| committer | Juri Linkov | 2006-02-23 21:41:26 +0000 |
| commit | 9b0f7f31c0e64d83bd379931c28d982a157da5b1 (patch) | |
| tree | 424056b0752738409954cb0798779eed919ae658 | |
| parent | 4e6d317052ad617bd403077d391d4c86ba3aee07 (diff) | |
| download | emacs-9b0f7f31c0e64d83bd379931c28d982a157da5b1.tar.gz emacs-9b0f7f31c0e64d83bd379931c28d982a157da5b1.zip | |
(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].
| -rw-r--r-- | lisp/compare-w.el | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/lisp/compare-w.el b/lisp/compare-w.el index 2d23de8c54c..e61f24a0c7c 100644 --- a/lisp/compare-w.el +++ b/lisp/compare-w.el | |||
| @@ -117,8 +117,14 @@ and the value `((4) (4))' for horizontally split windows." | |||
| 117 | :version "22.1") | 117 | :version "22.1") |
| 118 | 118 | ||
| 119 | (defcustom compare-windows-highlight t | 119 | (defcustom compare-windows-highlight t |
| 120 | "*Non-nil means compare-windows highlights the differences." | 120 | "*Non-nil means compare-windows highlights the differences. |
| 121 | :type 'boolean | 121 | The value t removes highlighting immediately after invoking a command |
| 122 | other than `compare-windows'. | ||
| 123 | The value `persistent' leaves all highlighted differences. You can clear | ||
| 124 | out all highlighting later with the command `compare-windows-dehighlight'." | ||
| 125 | :type '(choice (const :tag "No highlighting" nil) | ||
| 126 | (const :tag "Persistent highlighting" persistent) | ||
| 127 | (other :tag "Highlight until next command" t)) | ||
| 122 | :group 'compare-w | 128 | :group 'compare-w |
| 123 | :version "22.1") | 129 | :version "22.1") |
| 124 | 130 | ||
| @@ -130,6 +136,8 @@ and the value `((4) (4))' for horizontally split windows." | |||
| 130 | 136 | ||
| 131 | (defvar compare-windows-overlay1 nil) | 137 | (defvar compare-windows-overlay1 nil) |
| 132 | (defvar compare-windows-overlay2 nil) | 138 | (defvar compare-windows-overlay2 nil) |
| 139 | (defvar compare-windows-overlays1 nil) | ||
| 140 | (defvar compare-windows-overlays2 nil) | ||
| 133 | (defvar compare-windows-sync-point nil) | 141 | (defvar compare-windows-sync-point nil) |
| 134 | 142 | ||
| 135 | ;;;###autoload | 143 | ;;;###autoload |
| @@ -351,13 +359,22 @@ on third call it again advances points to the next difference and so on." | |||
| 351 | (overlay-put compare-windows-overlay2 'face 'compare-windows) | 359 | (overlay-put compare-windows-overlay2 'face 'compare-windows) |
| 352 | (overlay-put compare-windows-overlay2 'priority 1000)) | 360 | (overlay-put compare-windows-overlay2 'priority 1000)) |
| 353 | (overlay-put compare-windows-overlay2 'window w2) | 361 | (overlay-put compare-windows-overlay2 'window w2) |
| 354 | ;; Remove highlighting before next command is executed | 362 | (if (not (eq compare-windows-highlight 'persistent)) |
| 355 | (add-hook 'pre-command-hook 'compare-windows-dehighlight))) | 363 | ;; Remove highlighting before next command is executed |
| 364 | (add-hook 'pre-command-hook 'compare-windows-dehighlight) | ||
| 365 | (when compare-windows-overlay1 | ||
| 366 | (push (copy-overlay compare-windows-overlay1) compare-windows-overlays1) | ||
| 367 | (delete-overlay compare-windows-overlay1)) | ||
| 368 | (when compare-windows-overlay2 | ||
| 369 | (push (copy-overlay compare-windows-overlay2) compare-windows-overlays2) | ||
| 370 | (delete-overlay compare-windows-overlay2))))) | ||
| 356 | 371 | ||
| 357 | (defun compare-windows-dehighlight () | 372 | (defun compare-windows-dehighlight () |
| 358 | "Remove highlighting created by `compare-windows-highlight'." | 373 | "Remove highlighting created by `compare-windows-highlight'." |
| 359 | (interactive) | 374 | (interactive) |
| 360 | (remove-hook 'pre-command-hook 'compare-windows-dehighlight) | 375 | (remove-hook 'pre-command-hook 'compare-windows-dehighlight) |
| 376 | (mapc 'delete-overlay compare-windows-overlays1) | ||
| 377 | (mapc 'delete-overlay compare-windows-overlays2) | ||
| 361 | (and compare-windows-overlay1 (delete-overlay compare-windows-overlay1)) | 378 | (and compare-windows-overlay1 (delete-overlay compare-windows-overlay1)) |
| 362 | (and compare-windows-overlay2 (delete-overlay compare-windows-overlay2))) | 379 | (and compare-windows-overlay2 (delete-overlay compare-windows-overlay2))) |
| 363 | 380 | ||