Subject: bug#12438: 24.2; emacs-24.2 bidi Hebrew switch introduces editing error

From: Eli Zaretskii <[email-masked]>
Date: Fri, 14 Sep 2012 12:40:41 +0300

> Date: Fri, 14 Sep 2012 11:58:58 +0300
> From: Eli Zaretskii <[email-masked]>
> Cc: [email-masked]
> 
> However, I cannot figure out what exactly is the problem you are
> complaining about.  What "editing error" did you find, and how to
> reproduce it starting with "emacs -Q"?

If you mean the seemingly strange arrangement of characters (marked
with "^^^^") at the end of this line:

  [(z, ז), (x, ס), (c, ב), (v, ה), (b, נ), (n, מ), (m, צ), (, , ת
                                                       ^^^^^^^^^^

then this is not a bug.  This is how the Unicode standard prescribes
to display the sequence of characters at the end of that line.
Because the characters between צ and ת are all "neutral", i.e. have no
strong directionality attribute, these two Hebrew characters, which
are strong R2L characters, cause this entire run of characters between
them be rendered as R2L text, which includes mirroring of '(' as ')'.
In the other tuples on the above line, Latin characters, which are
strong L2R characters, after the '(' that begins the next tuple
prevent the text to be rendered as R2L.  But in the last tuple,
there's a space instead of a Latin character, and space has no strong
directionality.

If you want the end of that line be rendered as you expect, use the
LRM character, like this:

  [(z, ז), (x, ס), (c, ב), (v, ה), (b, נ), (n, מ), (m, צ), (‎,, ת)
                                                            ^

Here I inserted the LRM character (u+200E) before the comma, as marked
by "^".  LRM is a strong L2R character whose purpose is precisely to
"fix" display of mixed L2R/R2L text in such cases.  This character is
displayed by Emacs as a thin space, which makes it almost invisible on
display.  (See "C-h v glyphless-char-display" for other options of
displaying such characters.)