/ov-highlight

A persistent highlighter for Emacs

Primary LanguageEmacs Lisp

ov-highlight

ov-highlight provides a lightweight way to highlight text and put notes on them using overlays that are locally stored.

ov-highlight defines a local save-buffer-hook to automatically update and save highlights. It uses local file variables to load the highlights and apply them when the file is opened. All of the data is stored in a single line of base64 encoded text that is made mostly invisible by Emacs.

Features

Pre-defined highlights

There are several pre-defined highlights that are accessed from a hydra menu ov-highlight/body. I suggest you bind it to a key like H-h.

  • green, pink, yellow backgrounds
  • an interactive background chooser
  • an interactive text color chooser

There are several markups highlights:

  • bold, italic, underline, strikethrough, and box

You can change the font size as well as the font.

For editing, you can use typo, comment, delete and insert highlights.

Define your own highlights

The library defines a macro ov-make-highlight to make your own highlights. The macro takes a name, a face, and other properties as arguments.

For example, here is the type highlight that puts a reddish background and tooltip on the highlight.

(ov-highlight-make "typo" '(:background "PaleVioletRed1") help-echo "tpyo")

That macro creates the command ov-highlight-typo. See https://www.gnu.org/software/emacs/manual/html_node/elisp/Face-Attributes.html for details on setting face attributes.

List the highlights

You can use ov-highlight-display to see a list of the highlights, jump to one of them and delete one or all of them conveniently.

Cut/copy/paste highlights

ov-highlight-cut-copy-paste-on and ov-highlight-cut-copy-paste-off control whether you can copy and paste highlights around. This works within a buffer.

Write highlights to html

ov-highlight-html will write the buffer to an html file that retains the highlights.

Known limitations

Highlights are basically fragile. There are many ways to mess them up.

  1. You cannot edit the files with other editors, or the positions of the highlights will be messed up. This means if you put annotations in a file that is under version control, and then pull someone else’s changes in, the highlights are likely to break.
  2. The annotations will not export in org-mode. Highlights are presented as overlays, and are not part of the markup. There is some support to convert them to html using ov-highlight-html via the htmlize library.

Examples

Note: These will not be visible without installing ov-highlight. See README.html to see what they look like. Not all the markups convert to html, but most of them do. The tooltips are not preserved either.

  • green
  • pink
  • yellow
  • my choice (LightSalmon2)
  • dark red text

Markup examples

bold, italic, underlined, struck, boxed

Big, little, Comic Sans font

Delete this text, replace it with this. You mispleled this. You can also add comments.