diff options
| author | Paul Eggert | 2011-08-25 12:06:56 -0700 |
|---|---|---|
| committer | Paul Eggert | 2011-08-25 12:06:56 -0700 |
| commit | a974cdce9b9121158e623a3fab6ad731ff5d48ec (patch) | |
| tree | 689bdfe3830c42dea926a04079d9da9cfcbc9200 /src | |
| parent | 011ba6eaacfa50cc9871d0cfea34e8f0a7a5bc43 (diff) | |
| parent | e25be79236edca0e26a9fcd81b7f2a3746e8f9ef (diff) | |
| download | emacs-a974cdce9b9121158e623a3fab6ad731ff5d48ec.tar.gz emacs-a974cdce9b9121158e623a3fab6ad731ff5d48ec.zip | |
Merge from trunk.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 28 | ||||
| -rw-r--r-- | src/bidi.c | 71 | ||||
| -rw-r--r-- | src/buffer.c | 32 | ||||
| -rw-r--r-- | src/dispextern.h | 5 | ||||
| -rw-r--r-- | src/xdisp.c | 103 |
5 files changed, 158 insertions, 81 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 49d5325c224..b5ba1d74f8a 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | 2011-08-24 Paul Eggert <eggert@cs.ucla.edu> | 1 | 2011-08-25 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 2 | ||
| 3 | Integer and memory overflow issues (Bug#9196). | 3 | Integer and memory overflow issues (Bug#9196). |
| 4 | 4 | ||
| @@ -422,6 +422,32 @@ | |||
| 422 | (gs_load): Use printmax_t to print the widest integers possible. | 422 | (gs_load): Use printmax_t to print the widest integers possible. |
| 423 | Check for integer overflow when computing image height and width. | 423 | Check for integer overflow when computing image height and width. |
| 424 | 424 | ||
| 425 | 2011-08-25 Eli Zaretskii <eliz@gnu.org> | ||
| 426 | |||
| 427 | * xdisp.c (compute_display_string_pos): Return 2 in DISP_PROP when | ||
| 428 | the display spec is of the form `(space ...)'. | ||
| 429 | (handle_display_spec): Return the value returned by | ||
| 430 | handle_single_display_spec, not just 1 or zero. | ||
| 431 | (handle_single_display_spec): If the display spec is of the form | ||
| 432 | `(space ...)', and specifies display in the text area, return 2 | ||
| 433 | rather than 1. | ||
| 434 | (try_cursor_movement): Check for the need to scroll more | ||
| 435 | accurately, and prefer exact match for point under bidi. Don't | ||
| 436 | advance `row' beyond the last row of the window. | ||
| 437 | |||
| 438 | * dispextern.h (struct bidi_it): Rename the disp_prop_p member | ||
| 439 | into disp_prop; all users changed. | ||
| 440 | |||
| 441 | * bidi.c (bidi_fetch_char): If compute_display_string_pos returns | ||
| 442 | DISP_PROP = 2, substitute the u+2029 PARAGRAPH SEPARATOR character | ||
| 443 | for the text covered by the display property. | ||
| 444 | |||
| 445 | 2011-08-25 Chong Yidong <cyd@stupidchicken.com> | ||
| 446 | |||
| 447 | * buffer.c (Fbury_buffer_internal): Rename from Funrecord_buffer. | ||
| 448 | Change return value to nil. | ||
| 449 | (Frecord_buffer): Delete unused function. | ||
| 450 | |||
| 425 | 2011-08-24 Eli Zaretskii <eliz@gnu.org> | 451 | 2011-08-24 Eli Zaretskii <eliz@gnu.org> |
| 426 | 452 | ||
| 427 | * xdisp.c (Fcurrent_bidi_paragraph_direction): For unibyte | 453 | * xdisp.c (Fcurrent_bidi_paragraph_direction): For unibyte |
diff --git a/src/bidi.c b/src/bidi.c index 433c2cea2dc..564d985f890 100644 --- a/src/bidi.c +++ b/src/bidi.c | |||
| @@ -553,7 +553,7 @@ bidi_cache_iterator_state (struct bidi_it *bidi_it, int resolved) | |||
| 553 | bidi_cache[idx].next_for_ws = bidi_it->next_for_ws; | 553 | bidi_cache[idx].next_for_ws = bidi_it->next_for_ws; |
| 554 | bidi_cache[idx].ignore_bn_limit = bidi_it->ignore_bn_limit; | 554 | bidi_cache[idx].ignore_bn_limit = bidi_it->ignore_bn_limit; |
| 555 | bidi_cache[idx].disp_pos = bidi_it->disp_pos; | 555 | bidi_cache[idx].disp_pos = bidi_it->disp_pos; |
| 556 | bidi_cache[idx].disp_prop_p = bidi_it->disp_prop_p; | 556 | bidi_cache[idx].disp_prop = bidi_it->disp_prop; |
| 557 | } | 557 | } |
| 558 | 558 | ||
| 559 | bidi_cache_last_idx = idx; | 559 | bidi_cache_last_idx = idx; |
| @@ -827,7 +827,7 @@ bidi_init_it (EMACS_INT charpos, EMACS_INT bytepos, int frame_window_p, | |||
| 827 | bidi_it->prev_for_neutral.orig_type = UNKNOWN_BT; | 827 | bidi_it->prev_for_neutral.orig_type = UNKNOWN_BT; |
| 828 | bidi_it->sor = L2R; /* FIXME: should it be user-selectable? */ | 828 | bidi_it->sor = L2R; /* FIXME: should it be user-selectable? */ |
| 829 | bidi_it->disp_pos = -1; /* invalid/unknown */ | 829 | bidi_it->disp_pos = -1; /* invalid/unknown */ |
| 830 | bidi_it->disp_prop_p = 0; | 830 | bidi_it->disp_prop = 0; |
| 831 | /* We can only shrink the cache if we are at the bottom level of its | 831 | /* We can only shrink the cache if we are at the bottom level of its |
| 832 | "stack". */ | 832 | "stack". */ |
| 833 | if (bidi_cache_start == 0) | 833 | if (bidi_cache_start == 0) |
| @@ -907,19 +907,22 @@ bidi_char_at_pos (EMACS_INT bytepos, const unsigned char *s, int unibyte) | |||
| 907 | 907 | ||
| 908 | /* Fetch and return the character at BYTEPOS/CHARPOS. If that | 908 | /* Fetch and return the character at BYTEPOS/CHARPOS. If that |
| 909 | character is covered by a display string, treat the entire run of | 909 | character is covered by a display string, treat the entire run of |
| 910 | covered characters as a single character u+FFFC, and return their | 910 | covered characters as a single character, either u+2029 or u+FFFC, |
| 911 | combined length in CH_LEN and NCHARS. DISP_POS specifies the | 911 | and return their combined length in CH_LEN and NCHARS. DISP_POS |
| 912 | character position of the next display string, or -1 if not yet | 912 | specifies the character position of the next display string, or -1 |
| 913 | computed. DISP_PROP_P non-zero means that there's really a display | 913 | if not yet computed. DISP_PROP non-zero means that there's really |
| 914 | string at DISP_POS, as opposed to when we searched till DISP_POS | 914 | a display string at DISP_POS, as opposed to when we searched till |
| 915 | without findingone. When the next character is at or beyond that | 915 | DISP_POS without finding one. If DISP_PROP is 2, it means the |
| 916 | position, the function updates DISP_POS with the position of the | 916 | display spec is of the form `(space ...)', which is replaced with |
| 917 | next display string. STRING->s is the C string to iterate, or NULL | 917 | u+2029 to handle it as a paragraph separator. When the next |
| 918 | if iterating over a buffer or a Lisp string; in the latter case, | 918 | character is at or beyond that position, the function updates |
| 919 | STRING->lstring is the Lisp string. */ | 919 | DISP_POS with the position of the next display string. STRING->s |
| 920 | is the C string to iterate, or NULL if iterating over a buffer or a | ||
| 921 | Lisp string; in the latter case, STRING->lstring is the Lisp | ||
| 922 | string. */ | ||
| 920 | static inline int | 923 | static inline int |
| 921 | bidi_fetch_char (EMACS_INT bytepos, EMACS_INT charpos, EMACS_INT *disp_pos, | 924 | bidi_fetch_char (EMACS_INT bytepos, EMACS_INT charpos, EMACS_INT *disp_pos, |
| 922 | int *disp_prop_p, struct bidi_string_data *string, | 925 | int *disp_prop, struct bidi_string_data *string, |
| 923 | int frame_window_p, EMACS_INT *ch_len, EMACS_INT *nchars) | 926 | int frame_window_p, EMACS_INT *ch_len, EMACS_INT *nchars) |
| 924 | { | 927 | { |
| 925 | int ch; | 928 | int ch; |
| @@ -933,7 +936,7 @@ bidi_fetch_char (EMACS_INT bytepos, EMACS_INT charpos, EMACS_INT *disp_pos, | |||
| 933 | { | 936 | { |
| 934 | SET_TEXT_POS (pos, charpos, bytepos); | 937 | SET_TEXT_POS (pos, charpos, bytepos); |
| 935 | *disp_pos = compute_display_string_pos (&pos, string, frame_window_p, | 938 | *disp_pos = compute_display_string_pos (&pos, string, frame_window_p, |
| 936 | disp_prop_p); | 939 | disp_prop); |
| 937 | } | 940 | } |
| 938 | 941 | ||
| 939 | /* Fetch the character at BYTEPOS. */ | 942 | /* Fetch the character at BYTEPOS. */ |
| @@ -943,9 +946,9 @@ bidi_fetch_char (EMACS_INT bytepos, EMACS_INT charpos, EMACS_INT *disp_pos, | |||
| 943 | *ch_len = 1; | 946 | *ch_len = 1; |
| 944 | *nchars = 1; | 947 | *nchars = 1; |
| 945 | *disp_pos = endpos; | 948 | *disp_pos = endpos; |
| 946 | *disp_prop_p = 0; | 949 | *disp_prop = 0; |
| 947 | } | 950 | } |
| 948 | else if (charpos >= *disp_pos && *disp_prop_p) | 951 | else if (charpos >= *disp_pos && *disp_prop) |
| 949 | { | 952 | { |
| 950 | EMACS_INT disp_end_pos; | 953 | EMACS_INT disp_end_pos; |
| 951 | 954 | ||
| @@ -953,9 +956,23 @@ bidi_fetch_char (EMACS_INT bytepos, EMACS_INT charpos, EMACS_INT *disp_pos, | |||
| 953 | property. Hopefully, it will never be needed. */ | 956 | property. Hopefully, it will never be needed. */ |
| 954 | if (charpos > *disp_pos) | 957 | if (charpos > *disp_pos) |
| 955 | abort (); | 958 | abort (); |
| 956 | /* Return the Unicode Object Replacement Character to represent | 959 | /* Text covered by `display' properties and overlays with |
| 957 | the entire run of characters covered by the display string. */ | 960 | display properties or display strings is handled as a single |
| 958 | ch = 0xFFFC; | 961 | character that represents the entire run of characters |
| 962 | covered by the display property. */ | ||
| 963 | if (*disp_prop == 2) | ||
| 964 | { | ||
| 965 | /* `(space ...)' display specs are handled as paragraph | ||
| 966 | separators for the purposes of the reordering; see UAX#9 | ||
| 967 | section 3 and clause HL1 in section 4.3 there. */ | ||
| 968 | ch = 0x2029; | ||
| 969 | } | ||
| 970 | else | ||
| 971 | { | ||
| 972 | /* All other display specs are handled as the Unicode Object | ||
| 973 | Replacement Character. */ | ||
| 974 | ch = 0xFFFC; | ||
| 975 | } | ||
| 959 | disp_end_pos = compute_display_string_end (*disp_pos, string); | 976 | disp_end_pos = compute_display_string_end (*disp_pos, string); |
| 960 | *nchars = disp_end_pos - *disp_pos; | 977 | *nchars = disp_end_pos - *disp_pos; |
| 961 | if (*nchars <= 0) | 978 | if (*nchars <= 0) |
| @@ -1013,11 +1030,11 @@ bidi_fetch_char (EMACS_INT bytepos, EMACS_INT charpos, EMACS_INT *disp_pos, | |||
| 1013 | /* If we just entered a run of characters covered by a display | 1030 | /* If we just entered a run of characters covered by a display |
| 1014 | string, compute the position of the next display string. */ | 1031 | string, compute the position of the next display string. */ |
| 1015 | if (charpos + *nchars <= endpos && charpos + *nchars > *disp_pos | 1032 | if (charpos + *nchars <= endpos && charpos + *nchars > *disp_pos |
| 1016 | && *disp_prop_p) | 1033 | && *disp_prop) |
| 1017 | { | 1034 | { |
| 1018 | SET_TEXT_POS (pos, charpos + *nchars, bytepos + *ch_len); | 1035 | SET_TEXT_POS (pos, charpos + *nchars, bytepos + *ch_len); |
| 1019 | *disp_pos = compute_display_string_pos (&pos, string, frame_window_p, | 1036 | *disp_pos = compute_display_string_pos (&pos, string, frame_window_p, |
| 1020 | disp_prop_p); | 1037 | disp_prop); |
| 1021 | } | 1038 | } |
| 1022 | 1039 | ||
| 1023 | return ch; | 1040 | return ch; |
| @@ -1125,7 +1142,7 @@ bidi_paragraph_init (bidi_dir_t dir, struct bidi_it *bidi_it, int no_default_p) | |||
| 1125 | int ch; | 1142 | int ch; |
| 1126 | EMACS_INT ch_len, nchars; | 1143 | EMACS_INT ch_len, nchars; |
| 1127 | EMACS_INT pos, disp_pos = -1; | 1144 | EMACS_INT pos, disp_pos = -1; |
| 1128 | int disp_prop_p = 0; | 1145 | int disp_prop = 0; |
| 1129 | bidi_type_t type; | 1146 | bidi_type_t type; |
| 1130 | const unsigned char *s; | 1147 | const unsigned char *s; |
| 1131 | 1148 | ||
| @@ -1173,7 +1190,7 @@ bidi_paragraph_init (bidi_dir_t dir, struct bidi_it *bidi_it, int no_default_p) | |||
| 1173 | bytepos = pstartbyte; | 1190 | bytepos = pstartbyte; |
| 1174 | if (!string_p) | 1191 | if (!string_p) |
| 1175 | pos = BYTE_TO_CHAR (bytepos); | 1192 | pos = BYTE_TO_CHAR (bytepos); |
| 1176 | ch = bidi_fetch_char (bytepos, pos, &disp_pos, &disp_prop_p, | 1193 | ch = bidi_fetch_char (bytepos, pos, &disp_pos, &disp_prop, |
| 1177 | &bidi_it->string, | 1194 | &bidi_it->string, |
| 1178 | bidi_it->frame_window_p, &ch_len, &nchars); | 1195 | bidi_it->frame_window_p, &ch_len, &nchars); |
| 1179 | type = bidi_get_type (ch, NEUTRAL_DIR); | 1196 | type = bidi_get_type (ch, NEUTRAL_DIR); |
| @@ -1198,7 +1215,7 @@ bidi_paragraph_init (bidi_dir_t dir, struct bidi_it *bidi_it, int no_default_p) | |||
| 1198 | break; | 1215 | break; |
| 1199 | /* Fetch next character and advance to get past it. */ | 1216 | /* Fetch next character and advance to get past it. */ |
| 1200 | ch = bidi_fetch_char (bytepos, pos, &disp_pos, | 1217 | ch = bidi_fetch_char (bytepos, pos, &disp_pos, |
| 1201 | &disp_prop_p, &bidi_it->string, | 1218 | &disp_prop, &bidi_it->string, |
| 1202 | bidi_it->frame_window_p, &ch_len, &nchars); | 1219 | bidi_it->frame_window_p, &ch_len, &nchars); |
| 1203 | pos += nchars; | 1220 | pos += nchars; |
| 1204 | bytepos += ch_len; | 1221 | bytepos += ch_len; |
| @@ -1335,7 +1352,7 @@ bidi_resolve_explicit_1 (struct bidi_it *bidi_it) | |||
| 1335 | bidi_it->ch_len = 1; | 1352 | bidi_it->ch_len = 1; |
| 1336 | bidi_it->nchars = 1; | 1353 | bidi_it->nchars = 1; |
| 1337 | bidi_it->disp_pos = (string_p ? bidi_it->string.schars : ZV); | 1354 | bidi_it->disp_pos = (string_p ? bidi_it->string.schars : ZV); |
| 1338 | bidi_it->disp_prop_p = 0; | 1355 | bidi_it->disp_prop = 0; |
| 1339 | } | 1356 | } |
| 1340 | else | 1357 | else |
| 1341 | { | 1358 | { |
| @@ -1343,7 +1360,7 @@ bidi_resolve_explicit_1 (struct bidi_it *bidi_it) | |||
| 1343 | display string, treat the entire run of covered characters as | 1360 | display string, treat the entire run of covered characters as |
| 1344 | a single character u+FFFC. */ | 1361 | a single character u+FFFC. */ |
| 1345 | curchar = bidi_fetch_char (bidi_it->bytepos, bidi_it->charpos, | 1362 | curchar = bidi_fetch_char (bidi_it->bytepos, bidi_it->charpos, |
| 1346 | &bidi_it->disp_pos, &bidi_it->disp_prop_p, | 1363 | &bidi_it->disp_pos, &bidi_it->disp_prop, |
| 1347 | &bidi_it->string, bidi_it->frame_window_p, | 1364 | &bidi_it->string, bidi_it->frame_window_p, |
| 1348 | &bidi_it->ch_len, &bidi_it->nchars); | 1365 | &bidi_it->ch_len, &bidi_it->nchars); |
| 1349 | } | 1366 | } |
| @@ -2078,7 +2095,7 @@ bidi_level_of_next_char (struct bidi_it *bidi_it) | |||
| 2078 | struct bidi_string_data bs = bidi_it->string; | 2095 | struct bidi_string_data bs = bidi_it->string; |
| 2079 | bidi_type_t chtype; | 2096 | bidi_type_t chtype; |
| 2080 | int fwp = bidi_it->frame_window_p; | 2097 | int fwp = bidi_it->frame_window_p; |
| 2081 | int dpp = bidi_it->disp_prop_p; | 2098 | int dpp = bidi_it->disp_prop; |
| 2082 | 2099 | ||
| 2083 | if (bidi_it->nchars <= 0) | 2100 | if (bidi_it->nchars <= 0) |
| 2084 | abort (); | 2101 | abort (); |
diff --git a/src/buffer.c b/src/buffer.c index 5a6484e3105..37d2975c8c7 100644 --- a/src/buffer.c +++ b/src/buffer.c | |||
| @@ -1698,27 +1698,16 @@ record_buffer (Lisp_Object buffer) | |||
| 1698 | call1 (Vrun_hooks, Qbuffer_list_update_hook); | 1698 | call1 (Vrun_hooks, Qbuffer_list_update_hook); |
| 1699 | } | 1699 | } |
| 1700 | 1700 | ||
| 1701 | DEFUN ("record-buffer", Frecord_buffer, Srecord_buffer, 1, 1, 0, | ||
| 1702 | doc: /* Move BUFFER to the front of the buffer list. | ||
| 1703 | Return BUFFER. */) | ||
| 1704 | (Lisp_Object buffer) | ||
| 1705 | { | ||
| 1706 | CHECK_BUFFER (buffer); | ||
| 1707 | |||
| 1708 | record_buffer (buffer); | ||
| 1709 | |||
| 1710 | return buffer; | ||
| 1711 | } | ||
| 1712 | 1701 | ||
| 1713 | /* Move BUFFER to the end of the buffer (a)lists. Do nothing if the | 1702 | /* Move BUFFER to the end of the buffer (a)lists. Do nothing if the |
| 1714 | buffer is killed. For the selected frame's buffer list this moves | 1703 | buffer is killed. For the selected frame's buffer list this moves |
| 1715 | BUFFER to its end even if it was never shown in that frame. If | 1704 | BUFFER to its end even if it was never shown in that frame. If |
| 1716 | this happens we have a feature, hence `unrecord-buffer' should be | 1705 | this happens we have a feature, hence `unrecord-buffer' should be |
| 1717 | called only when BUFFER was shown in the selected frame. */ | 1706 | called only when BUFFER was shown in the selected frame. */ |
| 1718 | 1707 | ||
| 1719 | DEFUN ("unrecord-buffer", Funrecord_buffer, Sunrecord_buffer, 1, 1, 0, | 1708 | DEFUN ("bury-buffer-internal", Fbury_buffer_internal, Sbury_buffer_internal, |
| 1720 | doc: /* Move BUFFER to the end of the buffer list. | 1709 | 1, 1, 0, |
| 1721 | Return BUFFER. */) | 1710 | doc: /* Move BUFFER to the end of the buffer list. */) |
| 1722 | (Lisp_Object buffer) | 1711 | (Lisp_Object buffer) |
| 1723 | { | 1712 | { |
| 1724 | Lisp_Object aelt, aelt_cons, tem; | 1713 | Lisp_Object aelt, aelt_cons, tem; |
| @@ -1746,7 +1735,7 @@ Return BUFFER. */) | |||
| 1746 | if (!NILP (Vrun_hooks)) | 1735 | if (!NILP (Vrun_hooks)) |
| 1747 | call1 (Vrun_hooks, Qbuffer_list_update_hook); | 1736 | call1 (Vrun_hooks, Qbuffer_list_update_hook); |
| 1748 | 1737 | ||
| 1749 | return buffer; | 1738 | return Qnil; |
| 1750 | } | 1739 | } |
| 1751 | 1740 | ||
| 1752 | DEFUN ("set-buffer-major-mode", Fset_buffer_major_mode, Sset_buffer_major_mode, 1, 1, 0, | 1741 | DEFUN ("set-buffer-major-mode", Fset_buffer_major_mode, Sset_buffer_major_mode, 1, 1, 0, |
| @@ -6017,8 +6006,7 @@ Functions running this hook are `get-buffer-create', | |||
| 6017 | defsubr (&Sother_buffer); | 6006 | defsubr (&Sother_buffer); |
| 6018 | defsubr (&Sbuffer_enable_undo); | 6007 | defsubr (&Sbuffer_enable_undo); |
| 6019 | defsubr (&Skill_buffer); | 6008 | defsubr (&Skill_buffer); |
| 6020 | defsubr (&Srecord_buffer); | 6009 | defsubr (&Sbury_buffer_internal); |
| 6021 | defsubr (&Sunrecord_buffer); | ||
| 6022 | defsubr (&Sset_buffer_major_mode); | 6010 | defsubr (&Sset_buffer_major_mode); |
| 6023 | defsubr (&Scurrent_buffer); | 6011 | defsubr (&Scurrent_buffer); |
| 6024 | defsubr (&Sset_buffer); | 6012 | defsubr (&Sset_buffer); |
diff --git a/src/dispextern.h b/src/dispextern.h index 9cefea27e1c..f0be8ec136b 100644 --- a/src/dispextern.h +++ b/src/dispextern.h | |||
| @@ -1861,8 +1861,9 @@ struct bidi_it { | |||
| 1861 | bidi_dir_t sor; /* direction of start-of-run in effect */ | 1861 | bidi_dir_t sor; /* direction of start-of-run in effect */ |
| 1862 | int scan_dir; /* direction of text scan, 1: forw, -1: back */ | 1862 | int scan_dir; /* direction of text scan, 1: forw, -1: back */ |
| 1863 | EMACS_INT disp_pos; /* position of display string after ch */ | 1863 | EMACS_INT disp_pos; /* position of display string after ch */ |
| 1864 | int disp_prop_p; /* if non-zero, there really is a | 1864 | int disp_prop; /* if non-zero, there really is a |
| 1865 | `display' property/string at disp_pos */ | 1865 | `display' property/string at disp_pos; |
| 1866 | if 2, the property is a `space' spec */ | ||
| 1866 | int stack_idx; /* index of current data on the stack */ | 1867 | int stack_idx; /* index of current data on the stack */ |
| 1867 | /* Note: Everything from here on is not copied/saved when the bidi | 1868 | /* Note: Everything from here on is not copied/saved when the bidi |
| 1868 | iterator state is saved, pushed, or popped. So only put here | 1869 | iterator state is saved, pushed, or popped. So only put here |
diff --git a/src/xdisp.c b/src/xdisp.c index e7aee09682b..5f7020ba379 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -3143,11 +3143,15 @@ next_overlay_change (EMACS_INT pos) | |||
| 3143 | text property whose value is a string. STRING is data about the | 3143 | text property whose value is a string. STRING is data about the |
| 3144 | string to iterate; if STRING->lstring is nil, we are iterating a | 3144 | string to iterate; if STRING->lstring is nil, we are iterating a |
| 3145 | buffer. FRAME_WINDOW_P is non-zero when we are displaying a window | 3145 | buffer. FRAME_WINDOW_P is non-zero when we are displaying a window |
| 3146 | on a GUI frame. */ | 3146 | on a GUI frame. DISP_PROP is set to zero if we searched |
| 3147 | MAX_DISP_SCAN characters forward without finding any display | ||
| 3148 | strings, non-zero otherwise. It is set to 2 if the display string | ||
| 3149 | uses any kind of `(space ...)' spec that will produce a stretch of | ||
| 3150 | white space in the text area. */ | ||
| 3147 | EMACS_INT | 3151 | EMACS_INT |
| 3148 | compute_display_string_pos (struct text_pos *position, | 3152 | compute_display_string_pos (struct text_pos *position, |
| 3149 | struct bidi_string_data *string, | 3153 | struct bidi_string_data *string, |
| 3150 | int frame_window_p, int *disp_prop_p) | 3154 | int frame_window_p, int *disp_prop) |
| 3151 | { | 3155 | { |
| 3152 | /* OBJECT = nil means current buffer. */ | 3156 | /* OBJECT = nil means current buffer. */ |
| 3153 | Lisp_Object object = | 3157 | Lisp_Object object = |
| @@ -3160,8 +3164,9 @@ compute_display_string_pos (struct text_pos *position, | |||
| 3160 | EMACS_INT lim = | 3164 | EMACS_INT lim = |
| 3161 | (charpos < eob - MAX_DISP_SCAN) ? charpos + MAX_DISP_SCAN : eob; | 3165 | (charpos < eob - MAX_DISP_SCAN) ? charpos + MAX_DISP_SCAN : eob; |
| 3162 | struct text_pos tpos; | 3166 | struct text_pos tpos; |
| 3167 | int rv = 0; | ||
| 3163 | 3168 | ||
| 3164 | *disp_prop_p = 1; | 3169 | *disp_prop = 1; |
| 3165 | 3170 | ||
| 3166 | if (charpos >= eob | 3171 | if (charpos >= eob |
| 3167 | /* We don't support display properties whose values are strings | 3172 | /* We don't support display properties whose values are strings |
| @@ -3170,7 +3175,7 @@ compute_display_string_pos (struct text_pos *position, | |||
| 3170 | /* C strings cannot have display properties. */ | 3175 | /* C strings cannot have display properties. */ |
| 3171 | || (string->s && !STRINGP (object))) | 3176 | || (string->s && !STRINGP (object))) |
| 3172 | { | 3177 | { |
| 3173 | *disp_prop_p = 0; | 3178 | *disp_prop = 0; |
| 3174 | return eob; | 3179 | return eob; |
| 3175 | } | 3180 | } |
| 3176 | 3181 | ||
| @@ -3187,9 +3192,11 @@ compute_display_string_pos (struct text_pos *position, | |||
| 3187 | || !EQ (Fget_char_property (make_number (charpos - 1), Qdisplay, | 3192 | || !EQ (Fget_char_property (make_number (charpos - 1), Qdisplay, |
| 3188 | object), | 3193 | object), |
| 3189 | spec)) | 3194 | spec)) |
| 3190 | && handle_display_spec (NULL, spec, object, Qnil, &tpos, bufpos, | 3195 | && (rv = handle_display_spec (NULL, spec, object, Qnil, &tpos, bufpos, |
| 3191 | frame_window_p)) | 3196 | frame_window_p))) |
| 3192 | { | 3197 | { |
| 3198 | if (rv == 2) | ||
| 3199 | *disp_prop = 2; | ||
| 3193 | return charpos; | 3200 | return charpos; |
| 3194 | } | 3201 | } |
| 3195 | 3202 | ||
| @@ -3201,7 +3208,7 @@ compute_display_string_pos (struct text_pos *position, | |||
| 3201 | CHARPOS (tpos) = XFASTINT (pos); | 3208 | CHARPOS (tpos) = XFASTINT (pos); |
| 3202 | if (CHARPOS (tpos) >= lim) | 3209 | if (CHARPOS (tpos) >= lim) |
| 3203 | { | 3210 | { |
| 3204 | *disp_prop_p = 0; | 3211 | *disp_prop = 0; |
| 3205 | break; | 3212 | break; |
| 3206 | } | 3213 | } |
| 3207 | if (STRINGP (object)) | 3214 | if (STRINGP (object)) |
| @@ -3212,8 +3219,10 @@ compute_display_string_pos (struct text_pos *position, | |||
| 3212 | if (!STRINGP (object)) | 3219 | if (!STRINGP (object)) |
| 3213 | bufpos = CHARPOS (tpos); | 3220 | bufpos = CHARPOS (tpos); |
| 3214 | } while (NILP (spec) | 3221 | } while (NILP (spec) |
| 3215 | || !handle_display_spec (NULL, spec, object, Qnil, &tpos, bufpos, | 3222 | || !(rv = handle_display_spec (NULL, spec, object, Qnil, &tpos, |
| 3216 | frame_window_p)); | 3223 | bufpos, frame_window_p))); |
| 3224 | if (rv == 2) | ||
| 3225 | *disp_prop = 2; | ||
| 3217 | 3226 | ||
| 3218 | return CHARPOS (tpos); | 3227 | return CHARPOS (tpos); |
| 3219 | } | 3228 | } |
| @@ -4075,7 +4084,9 @@ handle_display_prop (struct it *it) | |||
| 4075 | /* Subroutine of handle_display_prop. Returns non-zero if the display | 4084 | /* Subroutine of handle_display_prop. Returns non-zero if the display |
| 4076 | specification in SPEC is a replacing specification, i.e. it would | 4085 | specification in SPEC is a replacing specification, i.e. it would |
| 4077 | replace the text covered by `display' property with something else, | 4086 | replace the text covered by `display' property with something else, |
| 4078 | such as an image or a display string. | 4087 | such as an image or a display string. If SPEC includes any kind or |
| 4088 | `(space ...) specification, the value is 2; this is used by | ||
| 4089 | compute_display_string_pos, which see. | ||
| 4079 | 4090 | ||
| 4080 | See handle_single_display_spec for documentation of arguments. | 4091 | See handle_single_display_spec for documentation of arguments. |
| 4081 | frame_window_p is non-zero if the window being redisplayed is on a | 4092 | frame_window_p is non-zero if the window being redisplayed is on a |
| @@ -4092,6 +4103,7 @@ handle_display_spec (struct it *it, Lisp_Object spec, Lisp_Object object, | |||
| 4092 | EMACS_INT bufpos, int frame_window_p) | 4103 | EMACS_INT bufpos, int frame_window_p) |
| 4093 | { | 4104 | { |
| 4094 | int replacing_p = 0; | 4105 | int replacing_p = 0; |
| 4106 | int rv; | ||
| 4095 | 4107 | ||
| 4096 | if (CONSP (spec) | 4108 | if (CONSP (spec) |
| 4097 | /* Simple specerties. */ | 4109 | /* Simple specerties. */ |
| @@ -4110,11 +4122,11 @@ handle_display_spec (struct it *it, Lisp_Object spec, Lisp_Object object, | |||
| 4110 | { | 4122 | { |
| 4111 | for (; CONSP (spec); spec = XCDR (spec)) | 4123 | for (; CONSP (spec); spec = XCDR (spec)) |
| 4112 | { | 4124 | { |
| 4113 | if (handle_single_display_spec (it, XCAR (spec), object, overlay, | 4125 | if ((rv = handle_single_display_spec (it, XCAR (spec), object, |
| 4114 | position, bufpos, replacing_p, | 4126 | overlay, position, bufpos, |
| 4115 | frame_window_p)) | 4127 | replacing_p, frame_window_p))) |
| 4116 | { | 4128 | { |
| 4117 | replacing_p = 1; | 4129 | replacing_p = rv; |
| 4118 | /* If some text in a string is replaced, `position' no | 4130 | /* If some text in a string is replaced, `position' no |
| 4119 | longer points to the position of `object'. */ | 4131 | longer points to the position of `object'. */ |
| 4120 | if (!it || STRINGP (object)) | 4132 | if (!it || STRINGP (object)) |
| @@ -4126,11 +4138,11 @@ handle_display_spec (struct it *it, Lisp_Object spec, Lisp_Object object, | |||
| 4126 | { | 4138 | { |
| 4127 | int i; | 4139 | int i; |
| 4128 | for (i = 0; i < ASIZE (spec); ++i) | 4140 | for (i = 0; i < ASIZE (spec); ++i) |
| 4129 | if (handle_single_display_spec (it, AREF (spec, i), object, overlay, | 4141 | if ((rv = handle_single_display_spec (it, AREF (spec, i), object, |
| 4130 | position, bufpos, replacing_p, | 4142 | overlay, position, bufpos, |
| 4131 | frame_window_p)) | 4143 | replacing_p, frame_window_p))) |
| 4132 | { | 4144 | { |
| 4133 | replacing_p = 1; | 4145 | replacing_p = rv; |
| 4134 | /* If some text in a string is replaced, `position' no | 4146 | /* If some text in a string is replaced, `position' no |
| 4135 | longer points to the position of `object'. */ | 4147 | longer points to the position of `object'. */ |
| 4136 | if (!it || STRINGP (object)) | 4148 | if (!it || STRINGP (object)) |
| @@ -4139,9 +4151,10 @@ handle_display_spec (struct it *it, Lisp_Object spec, Lisp_Object object, | |||
| 4139 | } | 4151 | } |
| 4140 | else | 4152 | else |
| 4141 | { | 4153 | { |
| 4142 | if (handle_single_display_spec (it, spec, object, overlay, | 4154 | if ((rv = handle_single_display_spec (it, spec, object, overlay, |
| 4143 | position, bufpos, 0, frame_window_p)) | 4155 | position, bufpos, 0, |
| 4144 | replacing_p = 1; | 4156 | frame_window_p))) |
| 4157 | replacing_p = rv; | ||
| 4145 | } | 4158 | } |
| 4146 | 4159 | ||
| 4147 | return replacing_p; | 4160 | return replacing_p; |
| @@ -4517,8 +4530,17 @@ handle_single_display_spec (struct it *it, Lisp_Object spec, Lisp_Object object, | |||
| 4517 | 4530 | ||
| 4518 | if (valid_p && !display_replaced_p) | 4531 | if (valid_p && !display_replaced_p) |
| 4519 | { | 4532 | { |
| 4533 | int retval = 1; | ||
| 4534 | |||
| 4520 | if (!it) | 4535 | if (!it) |
| 4521 | return 1; | 4536 | { |
| 4537 | /* Callers need to know whether the display spec is any kind | ||
| 4538 | of `(space ...)' spec that is about to affect text-area | ||
| 4539 | display. */ | ||
| 4540 | if (CONSP (value) && EQ (XCAR (value), Qspace) && NILP (location)) | ||
| 4541 | retval = 2; | ||
| 4542 | return retval; | ||
| 4543 | } | ||
| 4522 | 4544 | ||
| 4523 | /* Save current settings of IT so that we can restore them | 4545 | /* Save current settings of IT so that we can restore them |
| 4524 | when we are finished with the glyph property value. */ | 4546 | when we are finished with the glyph property value. */ |
| @@ -4576,6 +4598,7 @@ handle_single_display_spec (struct it *it, Lisp_Object spec, Lisp_Object object, | |||
| 4576 | it->method = GET_FROM_STRETCH; | 4598 | it->method = GET_FROM_STRETCH; |
| 4577 | it->object = value; | 4599 | it->object = value; |
| 4578 | *position = it->position = start_pos; | 4600 | *position = it->position = start_pos; |
| 4601 | retval = 1 + (it->area == TEXT_AREA); | ||
| 4579 | } | 4602 | } |
| 4580 | #ifdef HAVE_WINDOW_SYSTEM | 4603 | #ifdef HAVE_WINDOW_SYSTEM |
| 4581 | else | 4604 | else |
| @@ -4593,7 +4616,7 @@ handle_single_display_spec (struct it *it, Lisp_Object spec, Lisp_Object object, | |||
| 4593 | } | 4616 | } |
| 4594 | #endif /* HAVE_WINDOW_SYSTEM */ | 4617 | #endif /* HAVE_WINDOW_SYSTEM */ |
| 4595 | 4618 | ||
| 4596 | return 1; | 4619 | return retval; |
| 4597 | } | 4620 | } |
| 4598 | 4621 | ||
| 4599 | /* Invalid property or property not supported. Restore | 4622 | /* Invalid property or property not supported. Restore |
| @@ -5554,7 +5577,7 @@ forward_to_next_line_start (struct it *it, int *skipped_p, | |||
| 5554 | if (it->bidi_it.disp_pos < limit) | 5577 | if (it->bidi_it.disp_pos < limit) |
| 5555 | { | 5578 | { |
| 5556 | it->bidi_it.disp_pos = limit; | 5579 | it->bidi_it.disp_pos = limit; |
| 5557 | it->bidi_it.disp_prop_p = 0; | 5580 | it->bidi_it.disp_prop = 0; |
| 5558 | } | 5581 | } |
| 5559 | do { | 5582 | do { |
| 5560 | bprev = it->bidi_it; | 5583 | bprev = it->bidi_it; |
| @@ -14568,19 +14591,39 @@ try_cursor_movement (Lisp_Object window, struct text_pos startp, int *scroll_ste | |||
| 14568 | 14591 | ||
| 14569 | do | 14592 | do |
| 14570 | { | 14593 | { |
| 14594 | int at_zv_p = 0, exact_match_p = 0; | ||
| 14595 | |||
| 14571 | if (MATRIX_ROW_START_CHARPOS (row) <= PT | 14596 | if (MATRIX_ROW_START_CHARPOS (row) <= PT |
| 14572 | && PT <= MATRIX_ROW_END_CHARPOS (row) | 14597 | && PT <= MATRIX_ROW_END_CHARPOS (row) |
| 14573 | && cursor_row_p (row)) | 14598 | && cursor_row_p (row)) |
| 14574 | rv |= set_cursor_from_row (w, row, w->current_matrix, | 14599 | rv |= set_cursor_from_row (w, row, w->current_matrix, |
| 14575 | 0, 0, 0, 0); | 14600 | 0, 0, 0, 0); |
| 14576 | /* As soon as we've found the first suitable row | 14601 | /* As soon as we've found the exact match for point, |
| 14577 | whose ends_at_zv_p flag is set, we are done. */ | 14602 | or the first suitable row whose ends_at_zv_p flag |
| 14578 | if (rv | 14603 | is set, we are done. */ |
| 14579 | && MATRIX_ROW (w->current_matrix, w->cursor.vpos)->ends_at_zv_p) | 14604 | at_zv_p = |
| 14605 | MATRIX_ROW (w->current_matrix, w->cursor.vpos)->ends_at_zv_p; | ||
| 14606 | if (!at_zv_p) | ||
| 14607 | { | ||
| 14608 | struct glyph_row *candidate = | ||
| 14609 | MATRIX_ROW (w->current_matrix, w->cursor.vpos); | ||
| 14610 | struct glyph *g = | ||
| 14611 | candidate->glyphs[TEXT_AREA] + w->cursor.hpos; | ||
| 14612 | EMACS_INT endpos = MATRIX_ROW_END_CHARPOS (candidate); | ||
| 14613 | |||
| 14614 | exact_match_p = | ||
| 14615 | (BUFFERP (g->object) && g->charpos == PT) | ||
| 14616 | || (INTEGERP (g->object) | ||
| 14617 | && (g->charpos == PT | ||
| 14618 | || (g->charpos == 0 && endpos - 1 == PT))); | ||
| 14619 | } | ||
| 14620 | if (rv && (at_zv_p || exact_match_p)) | ||
| 14580 | { | 14621 | { |
| 14581 | rc = CURSOR_MOVEMENT_SUCCESS; | 14622 | rc = CURSOR_MOVEMENT_SUCCESS; |
| 14582 | break; | 14623 | break; |
| 14583 | } | 14624 | } |
| 14625 | if (MATRIX_ROW_BOTTOM_Y (row) == last_y) | ||
| 14626 | break; | ||
| 14584 | ++row; | 14627 | ++row; |
| 14585 | } | 14628 | } |
| 14586 | while (((MATRIX_ROW_CONTINUATION_LINE_P (row) | 14629 | while (((MATRIX_ROW_CONTINUATION_LINE_P (row) |
| @@ -14592,7 +14635,9 @@ try_cursor_movement (Lisp_Object window, struct text_pos startp, int *scroll_ste | |||
| 14592 | loop before all the candidates were examined, signal | 14635 | loop before all the candidates were examined, signal |
| 14593 | to the caller that this method failed. */ | 14636 | to the caller that this method failed. */ |
| 14594 | if (rc != CURSOR_MOVEMENT_SUCCESS | 14637 | if (rc != CURSOR_MOVEMENT_SUCCESS |
| 14595 | && (!rv || MATRIX_ROW_CONTINUATION_LINE_P (row))) | 14638 | && !(rv |
| 14639 | && !MATRIX_ROW_CONTINUATION_LINE_P (row) | ||
| 14640 | && !row->continued_p)) | ||
| 14596 | rc = CURSOR_MOVEMENT_MUST_SCROLL; | 14641 | rc = CURSOR_MOVEMENT_MUST_SCROLL; |
| 14597 | else if (rv) | 14642 | else if (rv) |
| 14598 | rc = CURSOR_MOVEMENT_SUCCESS; | 14643 | rc = CURSOR_MOVEMENT_SUCCESS; |