Gregg Reynolds | 26 Nov 15:58

Re: Bidi Emacs: R2L paragraphs and the direction of glyph_row

On Sat, Oct 17, 2009 at 3:15 AM, Eli Zaretskii <eliz <at> gnu.org> wrote:

This issue is borderline between design and implementation, but the
decision will affect lots of code to be written/changed later, so I'm
posting this here, in case there are some considerations that I
missed.

I've got lots of complaints about the way most bidi-enabled editors handle keyboard and cursor interaction; would a list of specific annoyances, er, use-cases be of any use?

For example, in Mellel (http://www.redlers.com/) I've discovered that if an RTL document starts with an LTR string, it is impossible to simply insert a linefeed in front of that string.  It's also a major pain to edit XML in a bidi editor.  And I do mean major.  If emacs could make it easy and natural to perform such operations it would be manna from heaven.

Cheers,

Gregg
_______________________________________________
emacs-bidi mailing list
emacs-bidi <at> gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-bidi
Martin J. Dürst | 27 Nov 12:11
Picon
Gravatar

Re: Bidi Emacs: R2L paragraphs and the direction of glyph_row

Hello Eli, Gregg,

On 2009/11/27 1:10, Eli Zaretskii wrote:
>> Date: Thu, 26 Nov 2009 08:58:39 -0600
>> From: Gregg Reynolds<gar <at> arabink.com>

>> It's also a major pain to edit XML in a bidi editor.  And I do mean
>> major.
>
> Again, an explicit list of main problems would be useful (although I
> deliberately decided not to handle bidirectional editing for meta
> documents yet, so this specific class of problems is still a long way
> from being dealt with).

This is a well-known problem. For some more background and some attempt 
at a solution, please see:

http://www.sw.it.aoyama.ac.jp/2005/pub/IUC28-bidi/ and
http://www.sw.it.aoyama.ac.jp/2008/pub/IUC32-bidi/

Unfortunately, the test prototype available at
http://www.sw.it.aoyama.ac.jp/2008/pub/IUC32-bidi/bidi-source.html
is not very usable currently because the carret jumps around and has to 
be repositioned. That problem has been solved, but I didn't get around 
to make the update publicly available. Anyway, both the simulation and 
the Web-based editor should make it possible to test your problem cases 
and tell us whether our solutions help (we know they aren't perfect; 
there is no such thing as perfect bidi, unfortunately).

Questions and comments are very welcome!

In a discussion with Ken'ichi Handa and Naoto Takahashi in 2005, they 
pointed out that using bidi marks in overlays should make it possible in 
bidi emacs to address this problem. Unfortunately, nobody here is 
familiar enough with emacs lisp to implement this, but I'd be very glad 
to help somebody with some emacs lisp skills to work on such a project.

Regards,    Martin.

--

-- 
#-# Martin J. Dürst, Professor, Aoyama Gakuin University
#-# http://www.sw.it.aoyama.ac.jp   mailto:duerst <at> it.aoyama.ac.jp
Eli Zaretskii | 27 Nov 13:24
Picon

Re: Bidi Emacs: R2L paragraphs and the direction of glyph_row

> Date: Fri, 27 Nov 2009 20:11:47 +0900
> From: "Martin J. Dürst" <duerst <at> it.aoyama.ac.jp>
> CC: Gregg Reynolds <gar <at> arabink.com>, emacs-bidi <at> gnu.org, emacs-devel <at> gnu.org
> 
> On 2009/11/27 1:10, Eli Zaretskii wrote:
> >> Date: Thu, 26 Nov 2009 08:58:39 -0600
> >> From: Gregg Reynolds<gar <at> arabink.com>
> 
> >> It's also a major pain to edit XML in a bidi editor.  And I do mean
> >> major.
> >
> > Again, an explicit list of main problems would be useful (although I
> > deliberately decided not to handle bidirectional editing for meta
> > documents yet, so this specific class of problems is still a long way
> > from being dealt with).
> 
> This is a well-known problem. For some more background and some attempt 
> at a solution, please see:
> 
> http://www.sw.it.aoyama.ac.jp/2005/pub/IUC28-bidi/ and
> http://www.sw.it.aoyama.ac.jp/2008/pub/IUC32-bidi/

Thanks.

As I pointed out elsewhere, this class of problems is currently beyond
the scope of what I'm trying to do in Emacs.  That is because the
display engine basically examines characters one by one, so correct
display of XML/HTML using just UAX#9 algorithm is impossible, as you
and others have found out.

I think that support for bidi editing of documents that use markup
languages should be based on the features that exist as part of the
markup: &lrm;/&rlm;, the dir= directive etc.  Using these, a Lisp
application should place overlays or maybe text properties on the
portions of text that need to be reordered.  For example, one could
place an overlay on a portion of the buffer with `display' property
whose value is the reordered text of that portion (it will have to be
enclosed in LRO..PDF embedding to avoid the automatic reordering when
the display string is delivered to the glass).  Or we could add a new
overlay property that would just tell the display engine "reorder this
part".  Then the display engine will DTRT guided by these overlays and
text properties.

However, please note that the above is not something I thought about
long enough to be convinced that it is the right solution.  The only
thing I convinced myself in at this point is that bidi support for
markup languages should not be on the basic display engine level,
which is what I'm currently hacking.  Rather, it should use the basic
reordering capabilities of the display engine in some way, but do some
additional work on higher levels to implement the equivalent of the
UAX#9 ``higher protocols''.

> In a discussion with Ken'ichi Handa and Naoto Takahashi in 2005, they 
> pointed out that using bidi marks in overlays should make it possible in 
> bidi emacs to address this problem. Unfortunately, nobody here is 
> familiar enough with emacs lisp to implement this, but I'd be very glad 
> to help somebody with some emacs lisp skills to work on such a project.

Thanks for the offer.  I don't know when I will get to those parts.
For now, text properties and overlays are not yet supported in the
modified display engine -- that is the very next problem on my agenda.
When these parts are done, hopefully others could come on board and
implement markup support on top of that.
Martin J. Dürst | 28 Nov 05:44
Picon
Gravatar

Re: Bidi Emacs: R2L paragraphs and the direction of glyph_row

Hello Eli,

Many thanks for your comments. I very much agree with what you say, 
namely that good display for HTML/XML (and similar stuff) should be at a 
level above the basic bidi support, and that it may be implemented by 
somebody else than you.

Nevertheless, I very much look forward to hear from Gregg (and others) 
about what they see as the current problems with bidi editing (such as 
the issue with carret placement that Gregg mentioned).

Regards,   Martin.

On 2009/11/27 21:24, Eli Zaretskii wrote:
>> Date: Fri, 27 Nov 2009 20:11:47 +0900
>> From: "Martin J. Dürst"<duerst <at> it.aoyama.ac.jp>
>> CC: Gregg Reynolds<gar <at> arabink.com>, emacs-bidi <at> gnu.org, emacs-devel <at> gnu.org
>>
>> On 2009/11/27 1:10, Eli Zaretskii wrote:
>>>> Date: Thu, 26 Nov 2009 08:58:39 -0600
>>>> From: Gregg Reynolds<gar <at> arabink.com>
>>
>>>> It's also a major pain to edit XML in a bidi editor.  And I do mean
>>>> major.
>>>
>>> Again, an explicit list of main problems would be useful (although I
>>> deliberately decided not to handle bidirectional editing for meta
>>> documents yet, so this specific class of problems is still a long way
>>> from being dealt with).
>>
>> This is a well-known problem. For some more background and some attempt
>> at a solution, please see:
>>
>> http://www.sw.it.aoyama.ac.jp/2005/pub/IUC28-bidi/ and
>> http://www.sw.it.aoyama.ac.jp/2008/pub/IUC32-bidi/
>
> Thanks.
>
> As I pointed out elsewhere, this class of problems is currently beyond
> the scope of what I'm trying to do in Emacs.  That is because the
> display engine basically examines characters one by one, so correct
> display of XML/HTML using just UAX#9 algorithm is impossible, as you
> and others have found out.
>
> I think that support for bidi editing of documents that use markup
> languages should be based on the features that exist as part of the
> markup:&lrm;/&rlm;, the dir= directive etc.  Using these, a Lisp
> application should place overlays or maybe text properties on the
> portions of text that need to be reordered.  For example, one could
> place an overlay on a portion of the buffer with `display' property
> whose value is the reordered text of that portion (it will have to be
> enclosed in LRO..PDF embedding to avoid the automatic reordering when
> the display string is delivered to the glass).  Or we could add a new
> overlay property that would just tell the display engine "reorder this
> part".  Then the display engine will DTRT guided by these overlays and
> text properties.
>
> However, please note that the above is not something I thought about
> long enough to be convinced that it is the right solution.  The only
> thing I convinced myself in at this point is that bidi support for
> markup languages should not be on the basic display engine level,
> which is what I'm currently hacking.  Rather, it should use the basic
> reordering capabilities of the display engine in some way, but do some
> additional work on higher levels to implement the equivalent of the
> UAX#9 ``higher protocols''.
>
>> In a discussion with Ken'ichi Handa and Naoto Takahashi in 2005, they
>> pointed out that using bidi marks in overlays should make it possible in
>> bidi emacs to address this problem. Unfortunately, nobody here is
>> familiar enough with emacs lisp to implement this, but I'd be very glad
>> to help somebody with some emacs lisp skills to work on such a project.
>
> Thanks for the offer.  I don't know when I will get to those parts.
> For now, text properties and overlays are not yet supported in the
> modified display engine -- that is the very next problem on my agenda.
> When these parts are done, hopefully others could come on board and
> implement markup support on top of that.
>

--

-- 
#-# Martin J. Dürst, Professor, Aoyama Gakuin University
#-# http://www.sw.it.aoyama.ac.jp   mailto:duerst <at> it.aoyama.ac.jp

Gmane