Fix display of R2L strings in mode line.
authorEli Zaretskii <eliz@gnu.org>
Thu, 16 Jun 2011 16:32:33 +0000 (19:32 +0300)
committerEli Zaretskii <eliz@gnu.org>
Thu, 16 Jun 2011 16:32:33 +0000 (19:32 +0300)
Composed characters still don't work.

 src/xdisp.c (init_iterator): Don't initialize it->bidi_p for strings
 here.
 (reseat_to_string): Initialize it->bidi_p for strings here.
 (next_element_from_string, next_element_from_c_string)
 (next_element_from_buffer): Add xassert's for correspondence
 between IT's object being iterated and it->bidi_it.string
 structure.
 src/bidi.c (bidi_level_of_next_char): Fix the logic for looking up
 the sentinel state in the cache.

src/ChangeLog
src/bidi.c
src/xdisp.c

index 5dc1c62..088ed07 100644 (file)
@@ -1,3 +1,16 @@
+2011-06-16  Eli Zaretskii  <eliz@gnu.org>
+
+       * xdisp.c (init_iterator): Don't initialize it->bidi_p for strings
+       here.
+       (reseat_to_string): Initialize it->bidi_p for strings here.
+       (next_element_from_string, next_element_from_c_string)
+       (next_element_from_buffer): Add xassert's for correspondence
+       between IT's object being iterated and it->bidi_it.string
+       structure.
+
+       * bidi.c (bidi_level_of_next_char): Fix the logic for looking up
+       the sentinel state in the cache.
+
 2011-06-13  Eli Zaretskii  <eliz@gnu.org>
 
        * xdisp.c (compute_display_string_pos)
index 169a3cb..ac01f65 100644 (file)
@@ -1660,7 +1660,7 @@ bidi_level_of_next_char (struct bidi_it *bidi_it)
   bidi_type_t type;
   int level, prev_level = -1;
   struct bidi_saved_info next_for_neutral;
-  EMACS_INT next_char_pos = -1;
+  EMACS_INT next_char_pos = -2;
 
   if (bidi_it->scan_dir == 1)
     {
@@ -1726,7 +1726,7 @@ bidi_level_of_next_char (struct bidi_it *bidi_it)
           that's the "position" of the sentinel iterator state we
           cached at the beginning of the iteration.  */
        next_char_pos = bidi_it->charpos - 1;
-      if (next_char_pos >= 0)
+      if (next_char_pos >= bob - 1)
        type = bidi_cache_find (next_char_pos, -1, bidi_it);
       else
        type = UNKNOWN_BT;
index c293dbe..00c66d4 100644 (file)
@@ -2405,13 +2405,6 @@ init_iterator (struct it *it, struct window *w,
   /* Are multibyte characters enabled in current_buffer?  */
   it->multibyte_p = !NILP (BVAR (current_buffer, enable_multibyte_characters));
 
-
-  /* Bidirectional reordering of strings is controlled by the default
-     value of bidi-display-reordering.  For buffers, we reconsider
-     this below.  */
-  it->bidi_p =
-    !NILP (BVAR (&buffer_defaults, bidi_display_reordering)) && it->multibyte_p;
-
   /* Non-zero if we should highlight the region.  */
   highlight_region_p
     = (!NILP (Vtransient_mark_mode)
@@ -5596,6 +5589,12 @@ reseat_to_string (struct it *it, const char *s, Lisp_Object string,
   if (multibyte >= 0)
     it->multibyte_p = multibyte > 0;
 
+  /* Bidirectional reordering of strings is controlled by the default
+     value of bidi-display-reordering.  */
+  it->bidi_p =
+    !NILP (BVAR (&buffer_defaults, bidi_display_reordering))
+    && it->multibyte_p;
+
   if (s == NULL)
     {
       xassert (STRINGP (string));
@@ -5607,7 +5606,6 @@ reseat_to_string (struct it *it, const char *s, Lisp_Object string,
 
       if (it->bidi_p)
        {
-         it->paragraph_embedding = NEUTRAL_DIR;
          it->bidi_it.string.lstring = string;
          it->bidi_it.string.s = NULL;
          it->bidi_it.string.schars = it->end_charpos;
@@ -5632,7 +5630,6 @@ reseat_to_string (struct it *it, const char *s, Lisp_Object string,
 
          if (it->bidi_p)
            {
-             it->paragraph_embedding = NEUTRAL_DIR;
              it->bidi_it.string.lstring = Qnil;
              it->bidi_it.string.s = s;
              it->bidi_it.string.schars = it->end_charpos;
@@ -6582,6 +6579,7 @@ next_element_from_string (struct it *it)
   struct text_pos position;
 
   xassert (STRINGP (it->string));
+  xassert (!it->bidi_p || it->string == it->bidi_it.string.lstring);
   xassert (IT_STRING_CHARPOS (*it) >= 0);
   position = it->current.string_pos;
 
@@ -6795,6 +6793,7 @@ next_element_from_c_string (struct it *it)
   int success_p = 1;
 
   xassert (it->s);
+  xassert (!it->bidi_p || it->s == it->bidi_it.string.s);
   it->what = IT_CHARACTER;
   BYTEPOS (it->position) = CHARPOS (it->position) = 0;
   it->object = Qnil;
@@ -6933,6 +6932,9 @@ next_element_from_buffer (struct it *it)
   int success_p = 1;
 
   xassert (IT_CHARPOS (*it) >= BEGV);
+  xassert (!it->bidi_p
+          || (it->bidi_it.string.lstring == Qnil
+              && it->bidi_it.string.s == NULL));
 
   /* With bidi reordering, the character to display might not be the
      character at IT_CHARPOS.  BIDI_IT.FIRST_ELT non-zero means that