0

I use Emacs to write LaTeX, and ran into the same problem as in this question, and for now I do as suggested in the questions answer. I've created some macros for making the process of adding the control characters more streamlined, however, I would want to be able to get rid of those characters entirely.

I want to develop some plugin that will find $ pairs, and make Emacs display them as LTR. I think if Emacs had a text-direction attribute for faces, that would be a good solution, however its seems that doesn't exist. The next best thing I can think of is make Emacs display selected characters as two characters in the buffer (in my case that would be to present a $ as a $ and a control character), but my intuition tells me that won't affect the bidi algorithm.

Any ideas for how to achieve this?

Erran
  • 11
  • 4
  • Have you already tried customizing the variables `bidi-directional-controls-chars` and `bidi-directional-non-controls-chars`? According to the doc-string of `bidi-paragraph-direction` ... "*If this is nil (the default), the direction of each paragraph is determined by the first strong directional character of its text. ...*" – lawlist Apr 16 '22 at 15:38
  • You might also want have a look inside `xdisp.c`; e.g., a comment that says ... "*Characters in unibyte strings are always treated by bidi.c as strong LTR*". And likewise, look inside `bidi.c` ... – lawlist Apr 16 '22 at 15:47
  • The question is too broad. Please pose only one question per post - a specific question. E.g. how to do . – Drew Apr 16 '22 at 16:21

1 Answers1

0

Emacs uses the bidi-class property of the character when it reorders bidirectional text for display. See Character Properties in the elisp manual.


To check the bidi-class of a specific character, here $:

(get-char-code-property ?$ 'bidi-class) ;; ET

To get a description of what is ET:

(char-code-property-description 'bidi-class 'ET) ;; "European Number Terminator"

Also see UAX #9: Bidirectional Character Types



To change the bidi-class of a specific character, for example to change $ to be a strong left-to-right character:

(put-char-code-property ?$ 'bidi-class 'L)

You might experiment with other values, but the above works for me.

Eissa
  • 1