all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Michael Welsh Duggan <md5i@md5i.com>
Cc: eli.osherovich@gmail.com, emacs-bidi@gnu.org, emacs-devel@gnu.org
Subject: Re: improving bidi documents display
Date: Sun, 27 Feb 2011 23:15:12 +0200	[thread overview]
Message-ID: <83aahhnpr3.fsf@gnu.org> (raw)
In-Reply-To: <87wrklpzii.fsf@maru.md5i.com>

> From: Michael Welsh Duggan <md5i@md5i.com>
> Cc: Eli Osherovich <eli.osherovich@gmail.com>,  emacs-devel@gnu.org, emacs-bidi@gnu.org
> Date: Sun, 27 Feb 2011 05:01:25 -0500
> 
> Memory:  HEBREW \foo{english}
> Levels:  11111111222222222221
> Display: {foo{english\ WERBEH

The key to a useful discussion of these matters is to decide up front
what do we want to support and what do we want the text to look like.

In this case, someone who knows about (La)TeX much more than I do
should first describe what TeX features would be useful when
typesetting bidirectional text.

With that knowledge in hand, we could then think whether the example
above is at all practical.  For example, most of the problems go away
if paragraphs have left-to-right direction; in that case the display
will be

   WERBEH \foo{english}

Maybe this is already good enough.

> One simple, naive way of handling this for the various TeXs is to
> consider all backslashes and brace characters as R characters.  This can
> be simulated by surrounding each run of these characters by LRE PDF
> pairs.  However, unless TeX ignores these characters completely, these
> formatting characters would have to be removed before being processed by
> TeX.

Again, someone who knows should tell if the bidi formatting codes need
to be removed before TeX'ing the file.

> Another way of handling this would be to redefine the backslash and
> brace characters as R characters, for purposes of the display engine.
> Currently, I don't know if there is a way to do this in elisp.  bidi.c
> seems to use a character table named bidi_type_table to hold this
> information.  Currently this table is not exposed at the elisp layer, to
> the best of my knowledge.  Maybe it would be possible to modify this
> table in elisp, and possibly make it buffer local?

I didn't expose the table to Lisp on purpose: messing with
bidirectional properties of characters is asking for trouble.  At
best, you will get text that will look different in any other editor;
at worst, you could easily crash Emacs.

> Another idea would be to allow a text property to override the character
> type.

Overlay, not text property.  The latter modifies the buffer, which is
not what you want in this case.

> This feels like a very elegant, emacs-ish way to do things, but
> an uneducated glance at the bidi code makes me feel like it would be
> difficult to get information about text properties into this layer.

You are looking at this from a wrong perspective.  The bidi reordering
engine doesn't need to access text properties or overlays; rather, the
display code should tell the reordering engine what to reorder.  The
reordering code already honors point-min and point-max, so all it
takes to do what you want is narrow the buffer to the portion of text
we want to reorder.  These portions could be marked by an overlay; the
display code already examines overlays as it goes about its job.

> Another idea would be to use display strings including the LRE and PDF
> characters to replace existing backslashes and braces.  However, display
> strings do not affect the bidi algorithm at this point.

I need a few rainy days to implement support for display strings.
However, it would be a mistake to base large portions of buffer
display on display strings, because they make redisplay too expensive.

  parent reply	other threads:[~2011-02-27 21:15 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-24 12:32 improving bidi documents display Eli Osherovich
2011-02-24 19:54 ` Eli Zaretskii
2011-02-27 10:01   ` Michael Welsh Duggan
2011-02-27 10:34     ` "Martin J. Dürst"
2011-02-27 21:19       ` Eli Zaretskii
2011-03-02  1:50         ` "Martin J. Dürst"
2011-03-02  4:02           ` Eli Zaretskii
2011-03-04 10:34             ` [emacs-bidi] " "Martin J. Dürst"
2011-02-27 21:15     ` Eli Zaretskii [this message]
2011-02-28  1:10       ` Miles Bader
2011-02-28  4:02         ` Eli Zaretskii
2011-03-02  0:58       ` James Cloos
2011-03-02 18:59         ` Eli Zaretskii
2011-03-02  2:09       ` [emacs-bidi] " "Martin J. Dürst"
2011-03-02  2:39         ` Miles Bader
2011-03-02  4:03           ` Eli Zaretskii
2011-03-02  7:06             ` Miles Bader
2011-03-02 18:39               ` Eli Zaretskii
2011-03-03  1:32                 ` Miles Bader
2011-03-03  4:07                   ` Eli Zaretskii
2011-03-03  6:11                     ` "Martin J. Dürst"
2011-03-03 10:40                       ` [emacs-bidi] " Eli Zaretskii
2011-03-04 10:34                         ` "Martin J. Dürst"
2011-03-04  3:58                 ` Stefan Monnier
2011-03-04  8:04                   ` Eli Zaretskii
2011-03-04  4:25                 ` Miles Bader
2011-03-04  9:52                   ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83aahhnpr3.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=eli.osherovich@gmail.com \
    --cc=emacs-bidi@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=md5i@md5i.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.