If you use library highlight-chars.el
you can highlight any characters any way you like.
Out of the box, you have command toggle-highlight-hard-hyphens
, as well as functions hc-highlight-hard-hyphens
and hc-dont-highlight-hard-hyphens
, all of which control just hard-hyphen (U+2011) highlighting.
Other than that, you have general commands and functions to highlight groups of characters. The most general of these are commands hc-highlight-chars
and hc-toggle-highlight-other-chars
. For hc-toggle-highlight-other-chars
, you can also specify characters that are to be excluded from
highlighting.
hc-highlight-chars is an interactive compiled Lisp function in
highlight-chars.el
.
(hc-highlight-chars CHARS FACE &optional OFFP MSGP)
Read a string of characters and a face name, then highlight the chars.
With a prefix arg, unhighlight the chars.
As an alternative to a string of characters, what you enter for the
characters can be any of the possibilities for a single entry in
hc-other-chars
. That is, it can be any of the following:
A cons (C1 . C2), where C1 and C2 are characters, that is, integers,
which you can represent using character notation. This represents
the range of characters from C1 through C2.
For example, you would enter (?a . ?g)
to mean the characters from
a
through g
, inclusive. Note that you enter the parentheses and
the dot, and you can use character read syntax (e.g., ?a
for a
).
A character class, such as [:digit:]
. This matches all characters
in the class. You must type the brackets and colons (:
).
A character set, such as iso-8859-1
or lao
. This matches all
characters in the set.
If you mistype one of the above representations, then what you type is
interpreted as just a string of the characters to highlight. For
example, if you mean to type [:digit:]
but you instead type
[:digit]
(no second colon), then the characters highlighted are
[, :, d, g, i, t, and ].
Non-interactively:
CHARS is a possible value for hc-other-chars
, that is, a list of
entries such as described above.
FACE is the face to use (e.g., a symbol).
Non-nil OFFP non-nil means turn highlighting off.