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.

Malabarba
  • 22,878
  • 6
  • 78
  • 163
Evan Aad
  • 1,461
  • 1
  • 14
  • 29

1 Answers1

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.

Dan
  • 32,584
  • 6
  • 98
  • 168
Drew
  • 75,699
  • 9
  • 109
  • 225
  • 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 05 '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 05 '15 at 16:02
  • Thank you. [This approach](http://emacs.stackexchange.com/questions/6052/how-to-set-the-glyph-of-a-unicode-character), though, is much better, imo. – Evan Aad Jan 06 '15 at 10:16