How can I use the highlight-chars.el package mentioned here (and here's its code) to highlight custom characters?

Specifically, I'd like to highlight the unicode directional formatting characters for embedding right-to-left languages in a predominantly left-to-right text and vice versa.

Before you say "But what do you need the directional formatting characters for? The newer versions of Emacs handle bidirectional text natively.", I'd like to remind you that there is a reason why the unicode algorithm allows for explicit bidirectional markers.

  • 1
    The documentation on your second link points to hc-highlight-chars. Did you try this?
    – Malabarba
    Commented Jan 4, 2015 at 21:18

1 Answer 1


@Malabarba's comment provides the answer. Try it interactively: M-x hc-highlight-chars.

It works for me. I use C-x 8 RET LEFT-TO-RIGHT EMBEDDING RET to insert character LRE (U+202A) in a buffer.

Then I use M-x hc-highlight-chars, and at the prompt I enter the same character (the same way: C-x 8 RET LEFT-TO-RIGHT EMBEDDING RET).

Then I hit RET again to tell it that there are no more chars to highlight.

Then I enter the face to use for the highlighting (e.g. highlight).

And I see a tiny vertical bar of highlighting, where the LRE char is.

You can also use it from Lisp code instead of interactively, of course.

  • Thank you. Three follow-up questions, please. (a) How can I cancel the highlighting? (b) Do you actually type "LEFT-TO-RIGHT EMBEDDING" where you indicated? Because when I do so, it highlights the letters L, E, F, T, etc. (c) How can I set-up the highlighting from my .emacs file?
    – Evan Aad
    Commented Jan 5, 2015 at 11:47
  • 2
    Please read the Commentary section in the source file. hc-highlight-chars unhighlights if you give it a prefix arg, etc. C-x 8 RET is the standard way to insert a Unicode character - see C-h k C-x 8 RET. When it prompts you for a char to insert, you can use completion against the char name, or you can give it the Unicode code point. From your init file, call hc-highlight-chars from Lisp - use a mode hook if you want it to be effective only for a particular mode, etc. If you have questions about these standard Emacs things, please post separate questions here (Emacs StackExhange).
    – Drew
    Commented Jan 5, 2015 at 16:02
  • Thank you. This approach, though, is much better, imo.
    – Evan Aad
    Commented Jan 6, 2015 at 10:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.