Subject: Re: bug#43207: 26.3; Strange bidi behavior

From: Eli Zaretskii <[email-masked]>
Date: Sat, 05 Sep 2020 10:35:52 +0300

> From: [email-masked] (Niels Möller)
> Cc: [email-masked]
> Date: Sat, 05 Sep 2020 08:46:51 +0200
> 
> Thanks for the explanation. So if the base paragraph direction is
> right-to-left, then right arrow is supposed to move logical backwards,
> like C-b.

Yes.

> > You can either insert an empty line between that Arabic line, 
> 
> Is there any way to tell emacs that a new paragraph starts, without
> inserting anything visible in the buffer? Some special unicode
> character, or emacs text property?

No, not at the moment.  FWIW, I don't think there's a significant need
for such a feature, given the related features we already have.

> > But this is how most bidi-supporting applications out there behave.
> 
> For what it's worth, display in firefox works differently. The line of
> arabic text is right-to-left and right-justified on the screen, but
> following lines are left-to-right, more like what I expected. So it
> seems to use a different parapgraph heuristics than emacs.

Yes, the Unicode Standard allows some leeway in this matter, and Emacs
uses it.  Firefox is not a text editor, so it doesn't need to cope
with the various situations we have every day in Emacs, where text
filling rearranges the words at the beginning of a physical line,
which generally can change the base direction at random (because the
base direction depends on the first string directional character of
the first line of the paragraph).

Because someone requested strict adherence to the Unicode
Bidirectional Algorithm in this particular matter, Emacs does support
the "each physical line starts a new paragraph" behavior; you will
find in the manual how to set that up using the variables
bidi-paragraph-start-re and bidi-paragraph-separate-re.  But I don't
recommend such a setup in Emacs, for the reasons I described above.