2

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 Jan 4 '15 at 21:18
3

@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 Jan 5 '15 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 Jan 5 '15 at 16:02
  • Thank you. This approach, though, is much better, imo. – Evan Aad Jan 6 '15 at 10:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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