From: Eli Zaretskii Date: Tue, 20 Sep 2011 17:42:16 +0000 (+0300) Subject: Fix bidi-aware cursor motion inside indentation. X-Git-Tag: emacs-pretest-24.0.90~67 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=fd317ddfc9ff0628af84aa1e9d298cea6a208d19;p=emacs.git Fix bidi-aware cursor motion inside indentation. src/xdisp.c (Fcurrent_bidi_paragraph_direction): Fix search for previous non-empty line. Fixes confusing cursor motion with arrow keys at the beginning of a line that starts with whitespace. --- diff --git a/src/ChangeLog b/src/ChangeLog index f0b1ecc3caa..17b53216e83 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -5,6 +5,9 @@ (find_row_edges): If the row ends in a newline from a display string, increment its MATRIX_ROW_END_CHARPOS by one. (Bug#9549) Handle the case of a display string with multiple newlines. + (Fcurrent_bidi_paragraph_direction): Fix search for previous + non-empty line. Fixes confusing cursor motion with arrow keys at + the beginning of a line that starts with whitespace. 2011-09-19 Lars Magne Ingebrigtsen diff --git a/src/xdisp.c b/src/xdisp.c index 81cba29206a..3505d18d502 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -19205,6 +19205,7 @@ See also `bidi-paragraph-direction'. */) EMACS_INT pos = BUF_PT (buf); EMACS_INT bytepos = BUF_PT_BYTE (buf); int c; + void *itb_data = bidi_shelve_cache (); set_buffer_temp (buf); /* bidi_paragraph_init finds the base direction of the paragraph @@ -19217,27 +19218,27 @@ See also `bidi-paragraph-direction'. */) pos--; bytepos = CHAR_TO_BYTE (pos); } - while ((c = FETCH_BYTE (bytepos)) == '\n' - || c == ' ' || c == '\t' || c == '\f') + if (fast_looking_at (build_string ("[\f\t ]*\n"), + pos, bytepos, ZV, ZV_BYTE, Qnil) > 0) { - if (bytepos <= BEGV_BYTE) - break; - bytepos--; - pos--; + while ((c = FETCH_BYTE (bytepos)) == '\n' + || c == ' ' || c == '\t' || c == '\f') + { + if (bytepos <= BEGV_BYTE) + break; + bytepos--; + pos--; + } + while (!CHAR_HEAD_P (FETCH_BYTE (bytepos))) + bytepos--; } - while (!CHAR_HEAD_P (FETCH_BYTE (bytepos))) - bytepos--; - itb.charpos = pos; - itb.bytepos = bytepos; - itb.nchars = -1; + bidi_init_it (pos, bytepos, FRAME_WINDOW_P (SELECTED_FRAME ()), &itb); itb.string.s = NULL; itb.string.lstring = Qnil; - itb.frame_window_p = FRAME_WINDOW_P (SELECTED_FRAME ()); /* guesswork */ - itb.first_elt = 1; - itb.separator_limit = -1; - itb.paragraph_dir = NEUTRAL_DIR; - + itb.string.bufpos = 0; + itb.string.unibyte = 0; bidi_paragraph_init (NEUTRAL_DIR, &itb, 1); + bidi_unshelve_cache (itb_data, 0); set_buffer_temp (old); switch (itb.paragraph_dir) {