aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2011-08-01 20:34:04 +0300
committerEli Zaretskii2011-08-01 20:34:04 +0300
commit525d5e6efa89c0435dca8fd80ed31b98fd3deed1 (patch)
treefda048753b6fa57a09f2c3435184e33189bca967 /src
parentcca09170ad19eb3c357052550765a2788fabbb40 (diff)
downloademacs-525d5e6efa89c0435dca8fd80ed31b98fd3deed1.tar.gz
emacs-525d5e6efa89c0435dca8fd80ed31b98fd3deed1.zip
Fix bug #9212 with selective-display under bidi.
src/xdisp.c (forward_to_next_line_start): Accept additional argument BIDI_IT_PREV, and store into it the state of the bidi iterator had on the newline. (reseat_at_next_visible_line_start): Use the bidi iterator state returned by forward_to_next_line_start to restore the state of it->bidi_it after backing up to previous newline. (Bug#9212)
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog9
-rw-r--r--src/xdisp.c51
2 files changed, 41 insertions, 19 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 623ccc6f4be..4e8217cdf5f 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,12 @@
12011-08-01 Eli Zaretskii <eliz@gnu.org>
2
3 * xdisp.c (forward_to_next_line_start): Accept additional argument
4 BIDI_IT_PREV, and store into it the state of the bidi iterator had
5 on the newline.
6 (reseat_at_next_visible_line_start): Use the bidi iterator state
7 returned by forward_to_next_line_start to restore the state of
8 it->bidi_it after backing up to previous newline. (Bug#9212)
9
12011-07-30 Andreas Schwab <schwab@linux-m68k.org> 102011-07-30 Andreas Schwab <schwab@linux-m68k.org>
2 11
3 * regex.c (re_comp): Protoize. 12 * regex.c (re_comp): Protoize.
diff --git a/src/xdisp.c b/src/xdisp.c
index 84c75bd91d9..a17d200c827 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -899,7 +899,7 @@ static void init_to_row_start (struct it *, struct window *,
899static int init_to_row_end (struct it *, struct window *, 899static int init_to_row_end (struct it *, struct window *,
900 struct glyph_row *); 900 struct glyph_row *);
901static void back_to_previous_line_start (struct it *); 901static void back_to_previous_line_start (struct it *);
902static int forward_to_next_line_start (struct it *, int *); 902static int forward_to_next_line_start (struct it *, int *, struct bidi_it *);
903static struct text_pos string_pos_nchars_ahead (struct text_pos, 903static struct text_pos string_pos_nchars_ahead (struct text_pos,
904 Lisp_Object, EMACS_INT); 904 Lisp_Object, EMACS_INT);
905static struct text_pos string_pos (EMACS_INT, Lisp_Object); 905static struct text_pos string_pos (EMACS_INT, Lisp_Object);
@@ -5494,6 +5494,9 @@ back_to_previous_line_start (struct it *it)
5494 continuously over the text). Otherwise, don't change the value 5494 continuously over the text). Otherwise, don't change the value
5495 of *SKIPPED_P. 5495 of *SKIPPED_P.
5496 5496
5497 If BIDI_IT_PREV is non-NULL, store into it the state of the bidi
5498 iterator on the newline, if it was found.
5499
5497 Newlines may come from buffer text, overlay strings, or strings 5500 Newlines may come from buffer text, overlay strings, or strings
5498 displayed via the `display' property. That's the reason we can't 5501 displayed via the `display' property. That's the reason we can't
5499 simply use find_next_newline_no_quit. 5502 simply use find_next_newline_no_quit.
@@ -5506,7 +5509,8 @@ back_to_previous_line_start (struct it *it)
5506 leads to wrong cursor motion. */ 5509 leads to wrong cursor motion. */
5507 5510
5508static int 5511static int
5509forward_to_next_line_start (struct it *it, int *skipped_p) 5512forward_to_next_line_start (struct it *it, int *skipped_p,
5513 struct bidi_it *bidi_it_prev)
5510{ 5514{
5511 EMACS_INT old_selective; 5515 EMACS_INT old_selective;
5512 int newline_found_p, n; 5516 int newline_found_p, n;
@@ -5518,6 +5522,8 @@ forward_to_next_line_start (struct it *it, int *skipped_p)
5518 && it->c == '\n' 5522 && it->c == '\n'
5519 && CHARPOS (it->position) == IT_CHARPOS (*it)) 5523 && CHARPOS (it->position) == IT_CHARPOS (*it))
5520 { 5524 {
5525 if (it->bidi_p && bidi_it_prev)
5526 *bidi_it_prev = it->bidi_it;
5521 set_iterator_to_next (it, 0); 5527 set_iterator_to_next (it, 0);
5522 it->c = 0; 5528 it->c = 0;
5523 return 1; 5529 return 1;
@@ -5539,6 +5545,8 @@ forward_to_next_line_start (struct it *it, int *skipped_p)
5539 if (!get_next_display_element (it)) 5545 if (!get_next_display_element (it))
5540 return 0; 5546 return 0;
5541 newline_found_p = it->what == IT_CHARACTER && it->c == '\n'; 5547 newline_found_p = it->what == IT_CHARACTER && it->c == '\n';
5548 if (newline_found_p && it->bidi_p && bidi_it_prev)
5549 *bidi_it_prev = it->bidi_it;
5542 set_iterator_to_next (it, 0); 5550 set_iterator_to_next (it, 0);
5543 } 5551 }
5544 5552
@@ -5573,6 +5581,8 @@ forward_to_next_line_start (struct it *it, int *skipped_p)
5573 && !newline_found_p) 5581 && !newline_found_p)
5574 { 5582 {
5575 newline_found_p = ITERATOR_AT_END_OF_LINE_P (it); 5583 newline_found_p = ITERATOR_AT_END_OF_LINE_P (it);
5584 if (newline_found_p && it->bidi_p && bidi_it_prev)
5585 *bidi_it_prev = it->bidi_it;
5576 set_iterator_to_next (it, 0); 5586 set_iterator_to_next (it, 0);
5577 } 5587 }
5578 } 5588 }
@@ -5696,8 +5706,9 @@ static void
5696reseat_at_next_visible_line_start (struct it *it, int on_newline_p) 5706reseat_at_next_visible_line_start (struct it *it, int on_newline_p)
5697{ 5707{
5698 int newline_found_p, skipped_p = 0; 5708 int newline_found_p, skipped_p = 0;
5709 struct bidi_it bidi_it_prev;
5699 5710
5700 newline_found_p = forward_to_next_line_start (it, &skipped_p); 5711 newline_found_p = forward_to_next_line_start (it, &skipped_p, &bidi_it_prev);
5701 5712
5702 /* Skip over lines that are invisible because they are indented 5713 /* Skip over lines that are invisible because they are indented
5703 more than the value of IT->selective. */ 5714 more than the value of IT->selective. */
@@ -5708,7 +5719,8 @@ reseat_at_next_visible_line_start (struct it *it, int on_newline_p)
5708 { 5719 {
5709 xassert (IT_BYTEPOS (*it) == BEGV 5720 xassert (IT_BYTEPOS (*it) == BEGV
5710 || FETCH_BYTE (IT_BYTEPOS (*it) - 1) == '\n'); 5721 || FETCH_BYTE (IT_BYTEPOS (*it) - 1) == '\n');
5711 newline_found_p = forward_to_next_line_start (it, &skipped_p); 5722 newline_found_p =
5723 forward_to_next_line_start (it, &skipped_p, &bidi_it_prev);
5712 } 5724 }
5713 5725
5714 /* Position on the newline if that's what's requested. */ 5726 /* Position on the newline if that's what's requested. */
@@ -5718,29 +5730,30 @@ reseat_at_next_visible_line_start (struct it *it, int on_newline_p)
5718 { 5730 {
5719 if (IT_STRING_CHARPOS (*it) > 0) 5731 if (IT_STRING_CHARPOS (*it) > 0)
5720 { 5732 {
5721 if (!it->bidi_p) 5733 --IT_STRING_CHARPOS (*it);
5734 --IT_STRING_BYTEPOS (*it);
5735 if (it->bidi_p)
5722 { 5736 {
5723 --IT_STRING_CHARPOS (*it); 5737 /* We need to restore the bidi iterator to the state
5724 --IT_STRING_BYTEPOS (*it); 5738 it had on the newline. */
5739 it->bidi_it = bidi_it_prev;
5740 xassert (IT_STRING_CHARPOS (*it) == it->bidi_it.charpos
5741 && IT_STRING_BYTEPOS (*it) == it->bidi_it.bytepos);
5725 } 5742 }
5726 else
5727 /* Setting this flag will cause
5728 bidi_move_to_visually_next not to advance, but
5729 instead deliver the current character (newline),
5730 which is what the ON_NEWLINE_P flag wants. */
5731 it->bidi_it.first_elt = 1;
5732 } 5743 }
5733 } 5744 }
5734 else if (IT_CHARPOS (*it) > BEGV) 5745 else if (IT_CHARPOS (*it) > BEGV)
5735 { 5746 {
5736 if (!it->bidi_p) 5747 --IT_CHARPOS (*it);
5748 --IT_BYTEPOS (*it);
5749 if (it->bidi_p)
5737 { 5750 {
5738 --IT_CHARPOS (*it); 5751 /* We need to restore the bidi iterator to the state it
5739 --IT_BYTEPOS (*it); 5752 had on the newline. */
5753 it->bidi_it = bidi_it_prev;
5754 xassert (IT_CHARPOS (*it) == it->bidi_it.charpos
5755 && IT_BYTEPOS (*it) == it->bidi_it.bytepos);
5740 } 5756 }
5741 /* With bidi iteration, the call to `reseat' will cause
5742 bidi_move_to_visually_next deliver the current character,
5743 the newline, instead of advancing. */
5744 reseat (it, it->current.pos, 0); 5757 reseat (it, it->current.pos, 0);
5745 } 5758 }
5746 } 5759 }