Subject: Re: bug#13399: 24.3.50; Word-wrap can't wrap at zero-width space U-200B

From: martin rudalics <[email-masked]>
Date: Fri, 11 Jan 2013 09:16:45 +0100

>> As can be seen in the window showing *foo*,
 >> lines are not regularly wrapped at that character.
 >
 > You mean, not wrapped at all.  Witness the continuation bitmaps in the
 > fringes, which shouldn't appear when a line is wrapped.

I thought these bitmaps appear when a line is wrapped.

 > If anything, this is a missing feature, since word-wrap is explicitly
 > coded to break lines only on SPC and TAB characters.

The doc-string of `word-wrap' says

   When word-wrapping is on, continuation lines are wrapped at the space
   or tab character nearest to the right window edge

Since U-200B is a space character the line should wrap at it.  Also

   this character is intended for invisible word separation and for line
   break control; it has no width, but its presence between two
   characters does not prevent increased letter spacing in justification

and Emacs apparently does handle it specially since it reserves a few
pixels when drawing it.  But documentation on `word-wrap' is scarce ...

 > See the
 > IT_DISPLAYING_WHITESPACE macro in xdisp.c.

I tried to understand the code but failed.

 > If we want to add more characters to the set, we should probably
 > arrange a special char-table for this, and have it exposed to Lisp, so
 > it could be customized.  Patches are welcome.

IIUC all breakable spaces are between U-2000 and U-200B so maybe a
character table is not needed.

Anway, exposing displayed text to Lisp would be great.  We'd just need
two functions - one that gets the pixel width of an arbitrary buffer
string wrt a specific window, and one that gets the pixel height of an
arbitrary buffer string (newlines ignored) wrt a specific window.  This
way we could get rid of lots of problems currently hidden in the display
engine ...

martin