81 |
;; |
;; |
82 |
;; Example usage: |
;; Example usage: |
83 |
;; (defun my-highlight-changes-enable-hook () |
;; (defun my-highlight-changes-enable-hook () |
84 |
;; (add-hook 'local-write-file-hooks 'highlight-changes-rotate-faces) |
;; (add-hook 'write-file-functions 'highlight-changes-rotate-faces nil t) |
85 |
;; ) |
;; ) |
86 |
;; |
;; |
87 |
;; (defun my-highlight-changes-disable-hook () |
;; (defun my-highlight-changes-disable-hook () |
88 |
;; (remove-hook 'local-write-file-hooks 'highlight-changes-rotate-faces) |
;; (remove-hook 'write-file-functions 'highlight-changes-rotate-faces t) |
89 |
;; ) |
;; ) |
90 |
;; |
;; |
91 |
;; (add-hook 'highlight-changes-enable-hook 'my-highlight-changes-enable-hook) |
;; (add-hook 'highlight-changes-enable-hook 'my-highlight-changes-enable-hook) |
213 |
;; indentation on inserts gets underlined (which can look pretty ugly!). |
;; indentation on inserts gets underlined (which can look pretty ugly!). |
214 |
|
|
215 |
(defface highlight-changes |
(defface highlight-changes |
216 |
'((((min-colors 88) (class color)) (:foreground "red1" )) |
'((((min-colors 88) (class color)) (:foreground "red1")) |
217 |
(((class color)) (:foreground "red" )) |
(((class color)) (:foreground "red" )) |
218 |
(t (:inverse-video t))) |
(t (:inverse-video t))) |
219 |
"Face used for highlighting changes." |
"Face used for highlighting changes." |
270 |
(defcustom highlight-changes-global-initial-state 'passive |
(defcustom highlight-changes-global-initial-state 'passive |
271 |
"*What state `global-highlight-changes' should start in. |
"*What state `global-highlight-changes' should start in. |
272 |
This is used if `global-highlight-changes' is called with no argument. |
This is used if `global-highlight-changes' is called with no argument. |
273 |
This variable must be set to either `active' or `passive'" |
This variable must be set to either `active' or `passive'." |
274 |
:type '(choice (const :tag "Active" active) |
:type '(choice (const :tag "Active" active) |
275 |
(const :tag "Passive" passive)) |
(const :tag "Passive" passive)) |
276 |
:group 'highlight-changes) |
:group 'highlight-changes) |
302 |
Changes mode, or a list whose first element is `not' followed by major |
Changes mode, or a list whose first element is `not' followed by major |
303 |
modes which are not suitable. |
modes which are not suitable. |
304 |
|
|
305 |
t means the buffer is suitable if it is visiting a file and its name |
A value of t means the buffer is suitable if it is visiting a file and |
306 |
does not begin with ` ' or `*'. |
its name does not begin with ` ' or `*'. |
307 |
|
|
308 |
A value of nil means no buffers are suitable for `global-highlight-changes' |
A value of nil means no buffers are suitable for `global-highlight-changes' |
309 |
\(effectively disabling the mode). |
\(effectively disabling the mode). |
488 |
"Fix change overlays in region between BEG and END. |
"Fix change overlays in region between BEG and END. |
489 |
|
|
490 |
Ensure the overlays agree with the changes as determined from |
Ensure the overlays agree with the changes as determined from |
491 |
the text properties of type `hilit-chg' ." |
the text properties of type `hilit-chg'." |
492 |
;; Remove or alter overlays in region beg..end |
;; Remove or alter overlays in region beg..end |
493 |
(let (ov-start ov-end props q) |
(let (ov-start ov-end props q) |
494 |
;; temp for debugging: |
;; temp for debugging: |
641 |
\\[highlight-changes-remove-highlight] - remove the change face from the region |
\\[highlight-changes-remove-highlight] - remove the change face from the region |
642 |
\\[highlight-changes-rotate-faces] - rotate different \"ages\" of changes \ |
\\[highlight-changes-rotate-faces] - rotate different \"ages\" of changes \ |
643 |
through |
through |
644 |
various faces. |
various faces |
645 |
|
|
646 |
Hook variables: |
Hook variables: |
647 |
`highlight-changes-enable-hook' - when enabling Highlight Changes mode. |
`highlight-changes-enable-hook' - when enabling Highlight Changes mode |
648 |
`highlight-changes-toggle-hook' - when entering active or passive state |
`highlight-changes-toggle-hook' - when entering active or passive state |
649 |
`highlight-changes-disable-hook' - when turning off Highlight Changes mode." |
`highlight-changes-disable-hook' - when turning off Highlight Changes mode" |
650 |
(interactive "P") |
(interactive "P") |
651 |
(if (or (display-color-p) |
(if (or (display-color-p) |
652 |
(and (fboundp 'x-display-grayscale-p) (x-display-grayscale-p))) |
(and (fboundp 'x-display-grayscale-p) (x-display-grayscale-p))) |
781 |
face described by the second element, and so on. Very old changes remain |
face described by the second element, and so on. Very old changes remain |
782 |
shown in the last face in the list. |
shown in the last face in the list. |
783 |
|
|
784 |
You can automatically rotate colors when the buffer is saved |
You can automatically rotate colors when the buffer is saved by adding |
785 |
by adding the following to `local-write-file-hooks', by evaling it in the |
this function to `write-file-functions' as a buffer-local value. To do |
786 |
buffer to be saved): |
this, eval the following in the buffer to be saved: |
787 |
|
|
788 |
\(add-hook 'local-write-file-hooks 'highlight-changes-rotate-faces)" |
\(add-hook 'write-file-functions 'highlight-changes-rotate-faces nil t)" |
789 |
(interactive) |
(interactive) |
790 |
;; If not in active mode do nothing but don't complain because this |
;; If not in active mode do nothing but don't complain because this |
791 |
;; may be bound to a hook. |
;; may be bound to a hook. |
800 |
;; and display them all if active |
;; and display them all if active |
801 |
(if (eq highlight-changes-mode 'active) |
(if (eq highlight-changes-mode 'active) |
802 |
(hilit-chg-display-changes)))) |
(hilit-chg-display-changes)))) |
803 |
;; This always returns nil so it is safe to use in |
;; This always returns nil so it is safe to use in write-file-functions |
|
;; local-write-file-hook |
|
804 |
nil) |
nil) |
805 |
|
|
806 |
;; ======================================================================== |
;; ======================================================================== |
885 |
If either buffer is modified and is visiting a file, you are prompted |
If either buffer is modified and is visiting a file, you are prompted |
886 |
to save the file. |
to save the file. |
887 |
|
|
888 |
Unless the buffer is unmodified and visiting a file, the buffer is |
Unless the buffer is unmodified and visiting a file, the buffer is |
889 |
written to a temporary file for comparison. |
written to a temporary file for comparison. |
890 |
|
|
891 |
If a buffer is read-only, differences will be highlighted but no property |
If a buffer is read-only, differences will be highlighted but no property |
1109 |
|
|
1110 |
A buffer is appropriate for Highlight Changes mode if all these are true: |
A buffer is appropriate for Highlight Changes mode if all these are true: |
1111 |
- the buffer is not a special buffer (one whose name begins with |
- the buffer is not a special buffer (one whose name begins with |
1112 |
`*' or ` ') |
`*' or ` '), |
1113 |
- the buffer's mode is suitable as per variable |
- the buffer's mode is suitable as per variable |
1114 |
`highlight-changes-global-modes' |
`highlight-changes-global-modes', |
1115 |
- Highlight Changes mode is not already on for this buffer. |
- Highlight Changes mode is not already on for this buffer. |
1116 |
|
|
1117 |
This function is called from `hilit-chg-update-all-buffers' or |
This function is called from `hilit-chg-update-all-buffers' or |