diff options
| author | Joakim Verona | 2011-09-19 11:37:46 +0200 |
|---|---|---|
| committer | Joakim Verona | 2011-09-19 11:37:46 +0200 |
| commit | 4caed0bee59613be5d2a6c4afabcdc43222f953e (patch) | |
| tree | d0c1debf666ef2107492e6cdd2bc8d6bb17de8a2 /src/bidi.c | |
| parent | c139d20a0c582a2c8fe3766128092c32b692ac23 (diff) | |
| parent | c5b01d8c63cfd14c95a029540a6fb0da84537726 (diff) | |
| download | emacs-4caed0bee59613be5d2a6c4afabcdc43222f953e.tar.gz emacs-4caed0bee59613be5d2a6c4afabcdc43222f953e.zip | |
upstream
Diffstat (limited to 'src/bidi.c')
| -rw-r--r-- | src/bidi.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/bidi.c b/src/bidi.c index bb29647ea88..3efdc1590df 100644 --- a/src/bidi.c +++ b/src/bidi.c | |||
| @@ -1071,15 +1071,25 @@ bidi_at_paragraph_end (EMACS_INT charpos, EMACS_INT bytepos) | |||
| 1071 | return val; | 1071 | return val; |
| 1072 | } | 1072 | } |
| 1073 | 1073 | ||
| 1074 | /* On my 2005-vintage machine, searching back for paragraph start | ||
| 1075 | takes ~1 ms per line. And bidi_paragraph_init is called 4 times | ||
| 1076 | when user types C-p. The number below limits each call to | ||
| 1077 | bidi_paragraph_init to about 10 ms. */ | ||
| 1078 | #define MAX_PARAGRAPH_SEARCH 7500 | ||
| 1079 | |||
| 1074 | /* Find the beginning of this paragraph by looking back in the buffer. | 1080 | /* Find the beginning of this paragraph by looking back in the buffer. |
| 1075 | Value is the byte position of the paragraph's beginning. */ | 1081 | Value is the byte position of the paragraph's beginning, or |
| 1082 | BEGV_BYTE if paragraph_start_re is still not found after looking | ||
| 1083 | back MAX_PARAGRAPH_SEARCH lines in the buffer. */ | ||
| 1076 | static EMACS_INT | 1084 | static EMACS_INT |
| 1077 | bidi_find_paragraph_start (EMACS_INT pos, EMACS_INT pos_byte) | 1085 | bidi_find_paragraph_start (EMACS_INT pos, EMACS_INT pos_byte) |
| 1078 | { | 1086 | { |
| 1079 | Lisp_Object re = paragraph_start_re; | 1087 | Lisp_Object re = paragraph_start_re; |
| 1080 | EMACS_INT limit = ZV, limit_byte = ZV_BYTE; | 1088 | EMACS_INT limit = ZV, limit_byte = ZV_BYTE; |
| 1089 | EMACS_INT n = 0; | ||
| 1081 | 1090 | ||
| 1082 | while (pos_byte > BEGV_BYTE | 1091 | while (pos_byte > BEGV_BYTE |
| 1092 | && n++ < MAX_PARAGRAPH_SEARCH | ||
| 1083 | && fast_looking_at (re, pos, pos_byte, limit, limit_byte, Qnil) < 0) | 1093 | && fast_looking_at (re, pos, pos_byte, limit, limit_byte, Qnil) < 0) |
| 1084 | { | 1094 | { |
| 1085 | /* FIXME: What if the paragraph beginning is covered by a | 1095 | /* FIXME: What if the paragraph beginning is covered by a |
| @@ -1089,6 +1099,8 @@ bidi_find_paragraph_start (EMACS_INT pos, EMACS_INT pos_byte) | |||
| 1089 | pos = find_next_newline_no_quit (pos - 1, -1); | 1099 | pos = find_next_newline_no_quit (pos - 1, -1); |
| 1090 | pos_byte = CHAR_TO_BYTE (pos); | 1100 | pos_byte = CHAR_TO_BYTE (pos); |
| 1091 | } | 1101 | } |
| 1102 | if (n >= MAX_PARAGRAPH_SEARCH) | ||
| 1103 | pos_byte = BEGV_BYTE; | ||
| 1092 | return pos_byte; | 1104 | return pos_byte; |
| 1093 | } | 1105 | } |
| 1094 | 1106 | ||
| @@ -2239,7 +2251,8 @@ bidi_move_to_visually_next (struct bidi_it *bidi_it) | |||
| 2239 | GCPRO1 (bidi_it->string.lstring); | 2251 | GCPRO1 (bidi_it->string.lstring); |
| 2240 | 2252 | ||
| 2241 | /* If we just passed a newline, initialize for the next line. */ | 2253 | /* If we just passed a newline, initialize for the next line. */ |
| 2242 | if (!bidi_it->first_elt && bidi_it->orig_type == NEUTRAL_B) | 2254 | if (!bidi_it->first_elt |
| 2255 | && (bidi_it->ch == '\n' || bidi_it->ch == BIDI_EOB)) | ||
| 2243 | bidi_line_init (bidi_it); | 2256 | bidi_line_init (bidi_it); |
| 2244 | 2257 | ||
| 2245 | /* Prepare the sentinel iterator state, and cache it. When we bump | 2258 | /* Prepare the sentinel iterator state, and cache it. When we bump |
| @@ -2320,7 +2333,8 @@ bidi_move_to_visually_next (struct bidi_it *bidi_it) | |||
| 2320 | reordering, whereas we _must_ know the paragraph base direction | 2333 | reordering, whereas we _must_ know the paragraph base direction |
| 2321 | _before_ we process the paragraph's text, since the base | 2334 | _before_ we process the paragraph's text, since the base |
| 2322 | direction affects the reordering. */ | 2335 | direction affects the reordering. */ |
| 2323 | if (bidi_it->scan_dir == 1 && bidi_it->orig_type == NEUTRAL_B) | 2336 | if (bidi_it->scan_dir == 1 |
| 2337 | && (bidi_it->ch == '\n' || bidi_it->ch == BIDI_EOB)) | ||
| 2324 | { | 2338 | { |
| 2325 | /* The paragraph direction of the entire string, once | 2339 | /* The paragraph direction of the entire string, once |
| 2326 | determined, is in effect for the entire string. Setting the | 2340 | determined, is in effect for the entire string. Setting the |