File: hilit-chg.el.html

A minor mode: "Highlight Changes mode".

When Highlight Changes mode is enabled changes to the buffer are recorded with a text property. Normally these ranges of text are displayed in a distinctive face. However, sometimes it is desirable to temporarily not see these changes. Instead of disabling Highlight Changes mode (which would remove the text property) use the command highlight-changes-visible-mode.

Two faces are supported: one for changed or inserted text and another for the first character after text has been deleted.

When Highlight Changes mode is on (even if changes are not visible) you can go to the next or previous change with highlight-changes-next-change or highlight-changes-previous-change.

Command highlight-compare-with-file shows changes in this file compared with another file (by default the previous version of the file).

The command highlight-compare-buffers compares two buffers by highlighting their differences.

You can "age" different sets of changes by using highlight-changes-rotate-faces. This rotates through a series of different faces, so you can distinguish "new" changes from "older" changes. You can customize these "rotated" faces in two ways. You can either explicitly define each face by customizing highlight-changes-face-list. If, however, the faces differ from highlight-changes-face only in the foreground color, you can simply set highlight-changes-colors. If highlight-changes-face-list is nil when the faces are required they will be constructed from highlight-changes-colors.

You can automatically rotate faces when the buffer is saved; see function highlight-changes-rotate-faces for how to do this.

The hook highlight-changes-mode-hook is called when Highlight Changes mode is turned on or off. When it called, variable highlight-changes-mode(var)/highlight-changes-mode(fun) has been updated to the new value.

Example usage:
(defun my-highlight-changes-mode-hook ()
  (if highlight-changes-mode
      (add-hook 'write-file-functions 'highlight-changes-rotate-faces nil t)
    (remove-hook 'write-file-functions 'highlight-changes-rotate-faces t)))


          Automatically enabling Highlight Changes mode


Normally, Highlight Changes mode is turned on explicitly in a buffer.

If you prefer to have it automatically invoked you can do it as follows.

1. Most modes have a major-hook, typically called MODE-hook. You
can use add-hook to call highlight-changes-mode(var)/highlight-changes-mode(fun).

  Example:
(add-hook 'c-mode-hook 'highlight-changes-mode)

However, this cannot be done for Fundamental mode for there is no such hook.

2. You can use the function global-highlight-changes-mode(var)/global-highlight-changes-mode(fun)

This function, which is fashioned after the way global-font-lock works, toggles on or off global Highlight Changes mode. When activated, it turns on Highlight Changes mode in all "suitable" existing buffers and will turn it on in new "suitable" buffers to be created.

A buffer's "suitability" is determined by variable highlight-changes-global-modes, as follows. If it is
* nil -- then no buffers are suitable;
* a function -- this function is called and the result is used. As
  an example, if the value is buffer-file-name(var)/buffer-file-name(fun) then all buffers
  who are visiting files are suitable, but others (like dired
  buffers) are not;
* a list -- then the buffer is suitable if and only if its mode is in the
  list, except if the first element is not, in which case the test
  is reversed (i.e. it is a list of unsuitable modes).
* Otherwise, the buffer is suitable if its name does not begin with
    or * and if buffer-file-name(var)/buffer-file-name(fun) returns true.

To enable it for future sessions put this in your ~/.emacs file:
(global-highlight-changes-mode t)


    Possible bindings:
(global-set-key '[C-right] #'highlight-changes-next-change)
(global-set-key '[C-left] #'highlight-changes-previous-change)

    Other interactive functions (that could be bound if desired):
highlight-changes-mode(var)/highlight-changes-mode(fun) highlight-changes-remove-highlight highlight-compare-with-file highlight-compare-buffers highlight-changes-rotate-faces

Defined variables (13)

global-highlight-changes-modeNon-nil if Global Highlight-Changes mode is enabled.
global-highlight-changes-mode-hookHook run after entering or leaving ‘global-highlight-changes-mode’.
highlight-changes-colorsColors used by ‘highlight-changes-rotate-faces’.
highlight-changes-face-listA list of faces used when rotating changes.
highlight-changes-global-changes-existing-buffersIf non-nil, toggling global Highlight Changes mode affects existing buffers.
highlight-changes-global-modesDetermine whether a buffer is suitable for global Highlight Changes mode.
highlight-changes-invisible-stringThe string used when in Highlight Changes mode and changes are hidden.
highlight-changes-modeNon-nil if Highlight-Changes mode is enabled.
highlight-changes-mode-hookHook run after entering or leaving ‘highlight-changes-mode’.
highlight-changes-visibility-initial-stateControls whether changes are initially visible in Highlight Changes mode.
highlight-changes-visible-modeNon-nil if Highlight-Changes-Visible mode is enabled.
highlight-changes-visible-mode-hookHook run after entering or leaving ‘highlight-changes-visible-mode’.
highlight-changes-visible-stringThe string used when in Highlight Changes mode and changes are visible.

Defined functions (26)

global-highlight-changes-mode(&optional ARG)
highlight-changes-mode(&optional ARG)
highlight-changes-mode-turn-on()
highlight-changes-next-change()
highlight-changes-previous-change()
highlight-changes-remove-highlight(BEG END)
highlight-changes-rotate-faces()
highlight-changes-visible-mode(&optional ARG)
highlight-compare-buffers(BUF-A BUF-B)
highlight-compare-with-file(FILE-B)
highlight-markup-buffers(BUF-A FILE-A BUF-B FILE-B &optional MARKUP-A-ONLY)
hilit-chg-bump-change(PROP START END)
hilit-chg-clear()
hilit-chg-cust-fix-changes-face-list(W WC &optional EVENT)
hilit-chg-desktop-restore(DESKTOP-BUFFER-LOCALS)
hilit-chg-display-changes(&optional BEG END)
hilit-chg-fixup(BEG END)
hilit-chg-get-diff-info(BUF-A FILE-A BUF-B FILE-B)
hilit-chg-hide-changes(&optional BEG END)
hilit-chg-make-list(&optional FORCE)
hilit-chg-make-ov(PROP START END)
hilit-chg-map-changes(FUNC &optional START-POSITION END-POSITION)
hilit-chg-set()
hilit-chg-set-face-on-change(BEG END LENG-BEFORE &optional NO-PROPERTY-CHANGE)
hilit-chg-unload-function()
hilit-chg-update()

Defined faces (2)

highlight-changesFace used for highlighting changes.
highlight-changes-deleteFace used for highlighting deletions.