aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2011-08-02 22:05:38 -0700
committerPaul Eggert2011-08-02 22:05:38 -0700
commit9a70f03d70e44db2ec9c6d2952cb8a1deae15000 (patch)
treec0efd5c0a208640c0a883f4566df1b40caa3aaad /src
parent29c8a348c5c9f326af54a3d30f69cde98fe300bb (diff)
downloademacs-9a70f03d70e44db2ec9c6d2952cb8a1deae15000.tar.gz
emacs-9a70f03d70e44db2ec9c6d2952cb8a1deae15000.zip
Merge from trunk.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog53
-rw-r--r--src/bidi.c44
-rw-r--r--src/chartab.c2
-rw-r--r--src/dispextern.h5
-rw-r--r--src/image.c10
-rw-r--r--src/keymap.c21
-rw-r--r--src/lisp.h1
-rw-r--r--src/regex.c7
-rw-r--r--src/w32term.c16
-rw-r--r--src/xdisp.c111
10 files changed, 172 insertions, 98 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 3eaa3d5eadd..3717924ff68 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,56 @@
12011-08-02 Eli Zaretskii <eliz@gnu.org>
2
3 Fix slow cursor motion and scrolling in large buffers with
4 selective display, like Org Mode buffers. (Bug#9218)
5
6 * dispextern.h (struct bidi_it): New member disp_prop_p.
7
8 * xdisp.c: Remove one-slot cache of display string positions.
9 (compute_display_string_pos): Accept an additional argument
10 DISP_PROP_P; callers changed. Scan at most 5K characters forward
11 for a display string or property. If found, set DISP_PROP_P
12 non-zero.
13
14 * bidi.c (bidi_fetch_char): Accept an additional argument
15 DISP_PROP_P, and pass it to compute_display_string_pos. Only
16 handle text covered by a display string if DISP_PROP_P is returned
17 non-zero. All callers of bidi_fetch_char changed.
18
192011-08-02 Stefan Monnier <monnier@iro.umontreal.ca>
20
21 * keymap.c (Fdefine_key): Fix Lisp_Object/int mixup; apply some CSE.
22
232010-12-03 Don March <don@ohspite.net>
24
25 * keymap.c (Fdefine_key): Fix non-prefix key error message when
26 last character M-[char] is translated to ESC [char] (bug#7541).
27
282011-08-02 Kenichi Handa <handa@m17n.org>
29
30 * lisp.h (uniprop_table): Extern it.
31
32 * chartab.c (uniprop_table): Make it non-static.
33
342011-08-01 Eli Zaretskii <eliz@gnu.org>
35
36 * xdisp.c (forward_to_next_line_start): Accept additional argument
37 BIDI_IT_PREV, and store into it the state of the bidi iterator had
38 on the newline.
39 (reseat_at_next_visible_line_start): Use the bidi iterator state
40 returned by forward_to_next_line_start to restore the state of
41 it->bidi_it after backing up to previous newline. (Bug#9212)
42
432011-07-30 Andreas Schwab <schwab@linux-m68k.org>
44
45 * regex.c (re_comp): Protoize.
46 (re_exec): Fix return type.
47 (regexec): Fix type of `ret'. (Bug#9203)
48
492011-07-29 Paul Eggert <eggert@cs.ucla.edu>
50
51 * image.c (check_image_size): Use 1024x1024 if unknown frame (Bug#9189).
52 This is needed if max-image-size is a floating-point number.
53
12011-07-28 Andreas Schwab <schwab@linux-m68k.org> 542011-07-28 Andreas Schwab <schwab@linux-m68k.org>
2 55
3 * print.c (print_object): Print empty symbol as ##. 56 * print.c (print_object): Print empty symbol as ##.
diff --git a/src/bidi.c b/src/bidi.c
index 697ebb92856..ae5143b37e0 100644
--- a/src/bidi.c
+++ b/src/bidi.c
@@ -792,6 +792,7 @@ bidi_init_it (EMACS_INT charpos, EMACS_INT bytepos, int frame_window_p,
792 bidi_it->prev_for_neutral.orig_type = UNKNOWN_BT; 792 bidi_it->prev_for_neutral.orig_type = UNKNOWN_BT;
793 bidi_it->sor = L2R; /* FIXME: should it be user-selectable? */ 793 bidi_it->sor = L2R; /* FIXME: should it be user-selectable? */
794 bidi_it->disp_pos = -1; /* invalid/unknown */ 794 bidi_it->disp_pos = -1; /* invalid/unknown */
795 bidi_it->disp_prop_p = 0;
795 /* We can only shrink the cache if we are at the bottom level of its 796 /* We can only shrink the cache if we are at the bottom level of its
796 "stack". */ 797 "stack". */
797 if (bidi_cache_start == 0) 798 if (bidi_cache_start == 0)
@@ -874,14 +875,16 @@ bidi_char_at_pos (EMACS_INT bytepos, const unsigned char *s, int unibyte)
874 covered characters as a single character u+FFFC, and return their 875 covered characters as a single character u+FFFC, and return their
875 combined length in CH_LEN and NCHARS. DISP_POS specifies the 876 combined length in CH_LEN and NCHARS. DISP_POS specifies the
876 character position of the next display string, or -1 if not yet 877 character position of the next display string, or -1 if not yet
877 computed. When the next character is at or beyond that position, 878 computed. DISP_PROP_P non-zero means that there's really a display
878 the function updates DISP_POS with the position of the next display 879 string at DISP_POS, as opposed to when we searched till DISP_POS
879 string. STRING->s is the C string to iterate, or NULL if iterating 880 without findingone. When the next character is at or beyond that
880 over a buffer or a Lisp string; in the latter case, STRING->lstring 881 position, the function updates DISP_POS with the position of the
881 is the Lisp string. */ 882 next display string. STRING->s is the C string to iterate, or NULL
883 if iterating over a buffer or a Lisp string; in the latter case,
884 STRING->lstring is the Lisp string. */
882static inline int 885static inline int
883bidi_fetch_char (EMACS_INT bytepos, EMACS_INT charpos, EMACS_INT *disp_pos, 886bidi_fetch_char (EMACS_INT bytepos, EMACS_INT charpos, EMACS_INT *disp_pos,
884 struct bidi_string_data *string, 887 int *disp_prop_p, struct bidi_string_data *string,
885 int frame_window_p, EMACS_INT *ch_len, EMACS_INT *nchars) 888 int frame_window_p, EMACS_INT *ch_len, EMACS_INT *nchars)
886{ 889{
887 int ch; 890 int ch;
@@ -894,7 +897,8 @@ bidi_fetch_char (EMACS_INT bytepos, EMACS_INT charpos, EMACS_INT *disp_pos,
894 if (charpos < endpos && charpos > *disp_pos) 897 if (charpos < endpos && charpos > *disp_pos)
895 { 898 {
896 SET_TEXT_POS (pos, charpos, bytepos); 899 SET_TEXT_POS (pos, charpos, bytepos);
897 *disp_pos = compute_display_string_pos (&pos, string, frame_window_p); 900 *disp_pos = compute_display_string_pos (&pos, string, frame_window_p,
901 disp_prop_p);
898 } 902 }
899 903
900 /* Fetch the character at BYTEPOS. */ 904 /* Fetch the character at BYTEPOS. */
@@ -904,8 +908,9 @@ bidi_fetch_char (EMACS_INT bytepos, EMACS_INT charpos, EMACS_INT *disp_pos,
904 *ch_len = 1; 908 *ch_len = 1;
905 *nchars = 1; 909 *nchars = 1;
906 *disp_pos = endpos; 910 *disp_pos = endpos;
911 *disp_prop_p = 0;
907 } 912 }
908 else if (charpos >= *disp_pos) 913 else if (charpos >= *disp_pos && *disp_prop_p)
909 { 914 {
910 EMACS_INT disp_end_pos; 915 EMACS_INT disp_end_pos;
911 916
@@ -972,10 +977,12 @@ bidi_fetch_char (EMACS_INT bytepos, EMACS_INT charpos, EMACS_INT *disp_pos,
972 977
973 /* If we just entered a run of characters covered by a display 978 /* If we just entered a run of characters covered by a display
974 string, compute the position of the next display string. */ 979 string, compute the position of the next display string. */
975 if (charpos + *nchars <= endpos && charpos + *nchars > *disp_pos) 980 if (charpos + *nchars <= endpos && charpos + *nchars > *disp_pos
981 && *disp_prop_p)
976 { 982 {
977 SET_TEXT_POS (pos, charpos + *nchars, bytepos + *ch_len); 983 SET_TEXT_POS (pos, charpos + *nchars, bytepos + *ch_len);
978 *disp_pos = compute_display_string_pos (&pos, string, frame_window_p); 984 *disp_pos = compute_display_string_pos (&pos, string, frame_window_p,
985 disp_prop_p);
979 } 986 }
980 987
981 return ch; 988 return ch;
@@ -1083,6 +1090,7 @@ bidi_paragraph_init (bidi_dir_t dir, struct bidi_it *bidi_it, int no_default_p)
1083 int ch; 1090 int ch;
1084 EMACS_INT ch_len, nchars; 1091 EMACS_INT ch_len, nchars;
1085 EMACS_INT pos, disp_pos = -1; 1092 EMACS_INT pos, disp_pos = -1;
1093 int disp_prop_p = 0;
1086 bidi_type_t type; 1094 bidi_type_t type;
1087 const unsigned char *s; 1095 const unsigned char *s;
1088 1096
@@ -1130,7 +1138,8 @@ bidi_paragraph_init (bidi_dir_t dir, struct bidi_it *bidi_it, int no_default_p)
1130 bytepos = pstartbyte; 1138 bytepos = pstartbyte;
1131 if (!string_p) 1139 if (!string_p)
1132 pos = BYTE_TO_CHAR (bytepos); 1140 pos = BYTE_TO_CHAR (bytepos);
1133 ch = bidi_fetch_char (bytepos, pos, &disp_pos, &bidi_it->string, 1141 ch = bidi_fetch_char (bytepos, pos, &disp_pos, &disp_prop_p,
1142 &bidi_it->string,
1134 bidi_it->frame_window_p, &ch_len, &nchars); 1143 bidi_it->frame_window_p, &ch_len, &nchars);
1135 type = bidi_get_type (ch, NEUTRAL_DIR); 1144 type = bidi_get_type (ch, NEUTRAL_DIR);
1136 1145
@@ -1157,7 +1166,8 @@ bidi_paragraph_init (bidi_dir_t dir, struct bidi_it *bidi_it, int no_default_p)
1157 && bidi_at_paragraph_end (pos, bytepos) >= -1) 1166 && bidi_at_paragraph_end (pos, bytepos) >= -1)
1158 break; 1167 break;
1159 /* Fetch next character and advance to get past it. */ 1168 /* Fetch next character and advance to get past it. */
1160 ch = bidi_fetch_char (bytepos, pos, &disp_pos, &bidi_it->string, 1169 ch = bidi_fetch_char (bytepos, pos, &disp_pos,
1170 &disp_prop_p, &bidi_it->string,
1161 bidi_it->frame_window_p, &ch_len, &nchars); 1171 bidi_it->frame_window_p, &ch_len, &nchars);
1162 pos += nchars; 1172 pos += nchars;
1163 bytepos += ch_len; 1173 bytepos += ch_len;
@@ -1290,6 +1300,7 @@ bidi_resolve_explicit_1 (struct bidi_it *bidi_it)
1290 bidi_it->ch_len = 1; 1300 bidi_it->ch_len = 1;
1291 bidi_it->nchars = 1; 1301 bidi_it->nchars = 1;
1292 bidi_it->disp_pos = (string_p ? bidi_it->string.schars : ZV); 1302 bidi_it->disp_pos = (string_p ? bidi_it->string.schars : ZV);
1303 bidi_it->disp_prop_p = 0;
1293 } 1304 }
1294 else 1305 else
1295 { 1306 {
@@ -1297,8 +1308,8 @@ bidi_resolve_explicit_1 (struct bidi_it *bidi_it)
1297 display string, treat the entire run of covered characters as 1308 display string, treat the entire run of covered characters as
1298 a single character u+FFFC. */ 1309 a single character u+FFFC. */
1299 curchar = bidi_fetch_char (bidi_it->bytepos, bidi_it->charpos, 1310 curchar = bidi_fetch_char (bidi_it->bytepos, bidi_it->charpos,
1300 &bidi_it->disp_pos, &bidi_it->string, 1311 &bidi_it->disp_pos, &bidi_it->disp_prop_p,
1301 bidi_it->frame_window_p, 1312 &bidi_it->string, bidi_it->frame_window_p,
1302 &bidi_it->ch_len, &bidi_it->nchars); 1313 &bidi_it->ch_len, &bidi_it->nchars);
1303 } 1314 }
1304 bidi_it->ch = curchar; 1315 bidi_it->ch = curchar;
@@ -2032,12 +2043,13 @@ bidi_level_of_next_char (struct bidi_it *bidi_it)
2032 struct bidi_string_data bs = bidi_it->string; 2043 struct bidi_string_data bs = bidi_it->string;
2033 bidi_type_t chtype; 2044 bidi_type_t chtype;
2034 int fwp = bidi_it->frame_window_p; 2045 int fwp = bidi_it->frame_window_p;
2046 int dpp = bidi_it->disp_prop_p;
2035 2047
2036 if (bidi_it->nchars <= 0) 2048 if (bidi_it->nchars <= 0)
2037 abort (); 2049 abort ();
2038 do { 2050 do {
2039 ch = bidi_fetch_char (bpos += clen, cpos += nc, &disp_pos, &bs, fwp, 2051 ch = bidi_fetch_char (bpos += clen, cpos += nc, &disp_pos, &dpp, &bs,
2040 &clen, &nc); 2052 fwp, &clen, &nc);
2041 if (ch == '\n' || ch == BIDI_EOB /* || ch == LINESEP_CHAR */) 2053 if (ch == '\n' || ch == BIDI_EOB /* || ch == LINESEP_CHAR */)
2042 chtype = NEUTRAL_B; 2054 chtype = NEUTRAL_B;
2043 else 2055 else
diff --git a/src/chartab.c b/src/chartab.c
index efe23eca83f..fb72004356e 100644
--- a/src/chartab.c
+++ b/src/chartab.c
@@ -1310,7 +1310,7 @@ uniprop_get_encoder (Lisp_Object table)
1310 function may load a Lisp file and thus may cause 1310 function may load a Lisp file and thus may cause
1311 garbage-collection. */ 1311 garbage-collection. */
1312 1312
1313static Lisp_Object 1313Lisp_Object
1314uniprop_table (Lisp_Object prop) 1314uniprop_table (Lisp_Object prop)
1315{ 1315{
1316 Lisp_Object val, table, result; 1316 Lisp_Object val, table, result;
diff --git a/src/dispextern.h b/src/dispextern.h
index dc44c698164..2e245479a81 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -1868,6 +1868,8 @@ struct bidi_it {
1868 bidi_dir_t paragraph_dir; /* current paragraph direction */ 1868 bidi_dir_t paragraph_dir; /* current paragraph direction */
1869 EMACS_INT separator_limit; /* where paragraph separator should end */ 1869 EMACS_INT separator_limit; /* where paragraph separator should end */
1870 EMACS_INT disp_pos; /* position of display string after ch */ 1870 EMACS_INT disp_pos; /* position of display string after ch */
1871 int disp_prop_p; /* if non-zero, there really is a
1872 `display' property/string at disp_pos */
1871 unsigned first_elt : 1; /* if non-zero, examine current char first */ 1873 unsigned first_elt : 1; /* if non-zero, examine current char first */
1872 unsigned new_paragraph : 1; /* if non-zero, we expect a new paragraph */ 1874 unsigned new_paragraph : 1; /* if non-zero, we expect a new paragraph */
1873 unsigned frame_window_p : 1; /* non-zero if displaying on a GUI frame */ 1875 unsigned frame_window_p : 1; /* non-zero if displaying on a GUI frame */
@@ -3035,7 +3037,8 @@ extern Lisp_Object lookup_glyphless_char_display (int, struct it *);
3035extern int calc_pixel_width_or_height (double *, struct it *, Lisp_Object, 3037extern int calc_pixel_width_or_height (double *, struct it *, Lisp_Object,
3036 struct font *, int, int *); 3038 struct font *, int, int *);
3037extern EMACS_INT compute_display_string_pos (struct text_pos *, 3039extern EMACS_INT compute_display_string_pos (struct text_pos *,
3038 struct bidi_string_data *, int); 3040 struct bidi_string_data *,
3041 int, int *);
3039extern EMACS_INT compute_display_string_end (EMACS_INT, 3042extern EMACS_INT compute_display_string_end (EMACS_INT,
3040 struct bidi_string_data *); 3043 struct bidi_string_data *);
3041 3044
diff --git a/src/image.c b/src/image.c
index fb1d825fa54..d1091aec6f3 100644
--- a/src/image.c
+++ b/src/image.c
@@ -1053,9 +1053,13 @@ check_image_size (struct frame *f, int width, int height)
1053 && height <= XINT (Vmax_image_size)); 1053 && height <= XINT (Vmax_image_size));
1054 else if (FLOATP (Vmax_image_size)) 1054 else if (FLOATP (Vmax_image_size))
1055 { 1055 {
1056 xassert (f); 1056 if (f != NULL)
1057 w = FRAME_PIXEL_WIDTH (f); 1057 {
1058 h = FRAME_PIXEL_HEIGHT (f); 1058 w = FRAME_PIXEL_WIDTH (f);
1059 h = FRAME_PIXEL_HEIGHT (f);
1060 }
1061 else
1062 w = h = 1024; /* Arbitrary size for unknown frame. */
1059 return (width <= XFLOAT_DATA (Vmax_image_size) * w 1063 return (width <= XFLOAT_DATA (Vmax_image_size) * w
1060 && height <= XFLOAT_DATA (Vmax_image_size) * h); 1064 && height <= XFLOAT_DATA (Vmax_image_size) * h);
1061 } 1065 }
diff --git a/src/keymap.c b/src/keymap.c
index 0169276bef9..c461fdddbbc 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -1216,13 +1216,20 @@ binding KEY to DEF is added at the front of KEYMAP. */)
1216 1216
1217 keymap = get_keymap (cmd, 0, 1); 1217 keymap = get_keymap (cmd, 0, 1);
1218 if (!CONSP (keymap)) 1218 if (!CONSP (keymap))
1219 /* We must use Fkey_description rather than just passing key to 1219 {
1220 error; key might be a vector, not a string. */ 1220 const char *trailing_esc = ((EQ (c, meta_prefix_char) && metized)
1221 error ("Key sequence %s starts with non-prefix key %s", 1221 ? (idx == 0 ? "ESC" : " ESC")
1222 SDATA (Fkey_description (key, Qnil)), 1222 : "");
1223 SDATA (Fkey_description (Fsubstring (key, make_number (0), 1223
1224 make_number (idx)), 1224 /* We must use Fkey_description rather than just passing key to
1225 Qnil))); 1225 error; key might be a vector, not a string. */
1226 error ("Key sequence %s starts with non-prefix key %s%s",
1227 SDATA (Fkey_description (key, Qnil)),
1228 SDATA (Fkey_description (Fsubstring (key, make_number (0),
1229 make_number (idx)),
1230 Qnil)),
1231 trailing_esc);
1232 }
1226 } 1233 }
1227} 1234}
1228 1235
diff --git a/src/lisp.h b/src/lisp.h
index 1e141dbb5d0..d82307b4332 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -2861,6 +2861,7 @@ extern void map_char_table_for_charset (void (*c_function) (Lisp_Object, Lisp_Ob
2861 Lisp_Object, Lisp_Object, 2861 Lisp_Object, Lisp_Object,
2862 Lisp_Object, struct charset *, 2862 Lisp_Object, struct charset *,
2863 unsigned, unsigned); 2863 unsigned, unsigned);
2864extern Lisp_Object uniprop_table (Lisp_Object);
2864extern void syms_of_chartab (void); 2865extern void syms_of_chartab (void);
2865 2866
2866/* Defined in print.c */ 2867/* Defined in print.c */
diff --git a/src/regex.c b/src/regex.c
index 862f848976c..545a198acd7 100644
--- a/src/regex.c
+++ b/src/regex.c
@@ -6381,8 +6381,7 @@ char *
6381 regcomp/regexec below without link errors. */ 6381 regcomp/regexec below without link errors. */
6382weak_function 6382weak_function
6383# endif 6383# endif
6384re_comp (s) 6384re_comp (const char *s)
6385 const char *s;
6386{ 6385{
6387 reg_errcode_t ret; 6386 reg_errcode_t ret;
6388 6387
@@ -6421,7 +6420,7 @@ re_comp (s)
6421} 6420}
6422 6421
6423 6422
6424regoff_t 6423int
6425# ifdef _LIBC 6424# ifdef _LIBC
6426weak_function 6425weak_function
6427# endif 6426# endif
@@ -6558,7 +6557,7 @@ reg_errcode_t
6558regexec (const regex_t *__restrict preg, const char *__restrict string, 6557regexec (const regex_t *__restrict preg, const char *__restrict string,
6559 size_t nmatch, regmatch_t pmatch[__restrict_arr], int eflags) 6558 size_t nmatch, regmatch_t pmatch[__restrict_arr], int eflags)
6560{ 6559{
6561 reg_errcode_t ret; 6560 regoff_t ret;
6562 struct re_registers regs; 6561 struct re_registers regs;
6563 regex_t private_preg; 6562 regex_t private_preg;
6564 size_t len = strlen (string); 6563 size_t len = strlen (string);
diff --git a/src/w32term.c b/src/w32term.c
index b7c0d61b633..98c4a391953 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -1439,7 +1439,7 @@ x_draw_glyphless_glyph_string_foreground (struct glyph_string *s)
1439 1439
1440 Nominally, highlight colors for `3d' faces are calculated by 1440 Nominally, highlight colors for `3d' faces are calculated by
1441 brightening an object's color by a constant scale factor, but this 1441 brightening an object's color by a constant scale factor, but this
1442 doesn't yield good results for dark colors, so for colors who's 1442 doesn't yield good results for dark colors, so for colors whose
1443 brightness is less than this value (on a scale of 0-255) have to 1443 brightness is less than this value (on a scale of 0-255) have to
1444 use an additional additive factor. 1444 use an additional additive factor.
1445 1445
@@ -1618,8 +1618,9 @@ x_setup_relief_colors (struct glyph_string *s)
1618 1618
1619static void 1619static void
1620w32_draw_relief_rect (struct frame *f, 1620w32_draw_relief_rect (struct frame *f,
1621 int left_x, int top_y, int right_x, int bottom_y, int width, 1621 int left_x, int top_y, int right_x, int bottom_y,
1622 int raised_p, int top_p, int bot_p, int left_p, int right_p, 1622 int width, int raised_p,
1623 int top_p, int bot_p, int left_p, int right_p,
1623 RECT *clip_rect) 1624 RECT *clip_rect)
1624{ 1625{
1625 int i; 1626 int i;
@@ -1880,7 +1881,8 @@ x_draw_image_relief (struct glyph_string *s)
1880 if (s->hl == DRAW_IMAGE_SUNKEN 1881 if (s->hl == DRAW_IMAGE_SUNKEN
1881 || s->hl == DRAW_IMAGE_RAISED) 1882 || s->hl == DRAW_IMAGE_RAISED)
1882 { 1883 {
1883 thick = tool_bar_button_relief >= 0 ? tool_bar_button_relief : DEFAULT_TOOL_BAR_BUTTON_RELIEF; 1884 thick = tool_bar_button_relief >= 0 ? tool_bar_button_relief
1885 : DEFAULT_TOOL_BAR_BUTTON_RELIEF;
1884 raised_p = s->hl == DRAW_IMAGE_RAISED; 1886 raised_p = s->hl == DRAW_IMAGE_RAISED;
1885 } 1887 }
1886 else 1888 else
@@ -3486,7 +3488,7 @@ my_destroy_window (struct frame * f, HWND hwnd)
3486 3488
3487/* Create a scroll bar and return the scroll bar vector for it. W is 3489/* Create a scroll bar and return the scroll bar vector for it. W is
3488 the Emacs window on which to create the scroll bar. TOP, LEFT, 3490 the Emacs window on which to create the scroll bar. TOP, LEFT,
3489 WIDTH and HEIGHT are.the pixel coordinates and dimensions of the 3491 WIDTH and HEIGHT are the pixel coordinates and dimensions of the
3490 scroll bar. */ 3492 scroll bar. */
3491 3493
3492static struct scroll_bar * 3494static struct scroll_bar *
@@ -3872,7 +3874,7 @@ w32_scroll_bar_handle_click (struct scroll_bar *bar, W32Msg *msg,
3872 si.fMask = SIF_POS; 3874 si.fMask = SIF_POS;
3873 si.nPos = y; 3875 si.nPos = y;
3874 /* Remember apparent position (we actually lag behind the real 3876 /* Remember apparent position (we actually lag behind the real
3875 position, so don't set that directly. */ 3877 position, so don't set that directly). */
3876 last_scroll_bar_drag_pos = y; 3878 last_scroll_bar_drag_pos = y;
3877 3879
3878 SetScrollInfo (SCROLL_BAR_W32_WINDOW (bar), SB_CTL, &si, FALSE); 3880 SetScrollInfo (SCROLL_BAR_W32_WINDOW (bar), SB_CTL, &si, FALSE);
@@ -4771,7 +4773,7 @@ w32_read_socket (struct terminal *terminal, int expected,
4771 pending_autoraise_frame = 0; 4773 pending_autoraise_frame = 0;
4772 } 4774 }
4773 4775
4774 /* Check which frames are still visisble, if we have enqueued any user 4776 /* Check which frames are still visible, if we have enqueued any user
4775 events or been notified of events that may affect visibility. We 4777 events or been notified of events that may affect visibility. We
4776 do this here because there doesn't seem to be any direct 4778 do this here because there doesn't seem to be any direct
4777 notification from Windows that the visibility of a window has 4779 notification from Windows that the visibility of a window has
diff --git a/src/xdisp.c b/src/xdisp.c
index 84c75bd91d9..fa4b3c4f9ab 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);
@@ -3134,13 +3134,10 @@ next_overlay_change (EMACS_INT pos)
3134 return endpos; 3134 return endpos;
3135} 3135}
3136 3136
3137/* Record one cached display string position found recently by 3137/* How many characters forward to search for a display property or
3138 compute_display_string_pos. */ 3138 display string. Enough for a screenful of 100 lines x 50
3139static EMACS_INT cached_disp_pos; 3139 characters in a line. */
3140static EMACS_INT cached_prev_pos = -1; 3140#define MAX_DISP_SCAN 5000
3141static struct buffer *cached_disp_buffer;
3142static int cached_disp_modiff;
3143static int cached_disp_overlay_modiff;
3144 3141
3145/* Return the character position of a display string at or after 3142/* Return the character position of a display string at or after
3146 position specified by POSITION. If no display string exists at or 3143 position specified by POSITION. If no display string exists at or
@@ -3152,57 +3149,33 @@ static int cached_disp_overlay_modiff;
3152 on a GUI frame. */ 3149 on a GUI frame. */
3153EMACS_INT 3150EMACS_INT
3154compute_display_string_pos (struct text_pos *position, 3151compute_display_string_pos (struct text_pos *position,
3155 struct bidi_string_data *string, int frame_window_p) 3152 struct bidi_string_data *string,
3153 int frame_window_p, int *disp_prop_p)
3156{ 3154{
3157 /* OBJECT = nil means current buffer. */ 3155 /* OBJECT = nil means current buffer. */
3158 Lisp_Object object = 3156 Lisp_Object object =
3159 (string && STRINGP (string->lstring)) ? string->lstring : Qnil; 3157 (string && STRINGP (string->lstring)) ? string->lstring : Qnil;
3160 Lisp_Object pos, spec; 3158 Lisp_Object pos, spec, limpos;
3161 int string_p = (string && (STRINGP (string->lstring) || string->s)); 3159 int string_p = (string && (STRINGP (string->lstring) || string->s));
3162 EMACS_INT eob = string_p ? string->schars : ZV; 3160 EMACS_INT eob = string_p ? string->schars : ZV;
3163 EMACS_INT begb = string_p ? 0 : BEGV; 3161 EMACS_INT begb = string_p ? 0 : BEGV;
3164 EMACS_INT bufpos, charpos = CHARPOS (*position); 3162 EMACS_INT bufpos, charpos = CHARPOS (*position);
3163 EMACS_INT lim =
3164 (charpos < eob - MAX_DISP_SCAN) ? charpos + MAX_DISP_SCAN : eob;
3165 struct text_pos tpos; 3165 struct text_pos tpos;
3166 struct buffer *b; 3166 struct buffer *b;
3167 3167
3168 *disp_prop_p = 1;
3169
3168 if (charpos >= eob 3170 if (charpos >= eob
3169 /* We don't support display properties whose values are strings 3171 /* We don't support display properties whose values are strings
3170 that have display string properties. */ 3172 that have display string properties. */
3171 || string->from_disp_str 3173 || string->from_disp_str
3172 /* C strings cannot have display properties. */ 3174 /* C strings cannot have display properties. */
3173 || (string->s && !STRINGP (object))) 3175 || (string->s && !STRINGP (object)))
3174 return eob;
3175
3176 /* Check the cached values. */
3177 if (!STRINGP (object))
3178 { 3176 {
3179 if (NILP (object)) 3177 *disp_prop_p = 0;
3180 b = current_buffer; 3178 return eob;
3181 else
3182 b = XBUFFER (object);
3183 if (b == cached_disp_buffer
3184 && BUF_MODIFF (b) == cached_disp_modiff
3185 && BUF_OVERLAY_MODIFF (b) == cached_disp_overlay_modiff
3186 && !b->clip_changed)
3187 {
3188 if (cached_prev_pos >= 0
3189 && cached_prev_pos < charpos && charpos <= cached_disp_pos)
3190 return cached_disp_pos;
3191 /* Handle overstepping either end of the known interval. */
3192 if (charpos > cached_disp_pos)
3193 cached_prev_pos = cached_disp_pos;
3194 else /* charpos <= cached_prev_pos */
3195 cached_prev_pos = max (charpos - 1, 0);
3196 }
3197
3198 /* Record new values in the cache. */
3199 if (b != cached_disp_buffer)
3200 {
3201 cached_disp_buffer = b;
3202 cached_prev_pos = max (charpos - 1, 0);
3203 }
3204 cached_disp_modiff = BUF_MODIFF (b);
3205 cached_disp_overlay_modiff = BUF_OVERLAY_MODIFF (b);
3206 } 3179 }
3207 3180
3208 /* If the character at CHARPOS is where the display string begins, 3181 /* If the character at CHARPOS is where the display string begins,
@@ -3221,22 +3194,24 @@ compute_display_string_pos (struct text_pos *position,
3221 && handle_display_spec (NULL, spec, object, Qnil, &tpos, bufpos, 3194 && handle_display_spec (NULL, spec, object, Qnil, &tpos, bufpos,
3222 frame_window_p)) 3195 frame_window_p))
3223 { 3196 {
3224 if (!STRINGP (object))
3225 cached_disp_pos = charpos;
3226 return charpos; 3197 return charpos;
3227 } 3198 }
3228 3199
3229 /* Look forward for the first character with a `display' property 3200 /* Look forward for the first character with a `display' property
3230 that will replace the underlying text when displayed. */ 3201 that will replace the underlying text when displayed. */
3202 limpos = make_number (lim);
3231 do { 3203 do {
3232 pos = Fnext_single_char_property_change (pos, Qdisplay, object, Qnil); 3204 pos = Fnext_single_char_property_change (pos, Qdisplay, object, limpos);
3233 CHARPOS (tpos) = XFASTINT (pos); 3205 CHARPOS (tpos) = XFASTINT (pos);
3206 if (CHARPOS (tpos) >= lim)
3207 {
3208 *disp_prop_p = 0;
3209 break;
3210 }
3234 if (STRINGP (object)) 3211 if (STRINGP (object))
3235 BYTEPOS (tpos) = string_char_to_byte (object, CHARPOS (tpos)); 3212 BYTEPOS (tpos) = string_char_to_byte (object, CHARPOS (tpos));
3236 else 3213 else
3237 BYTEPOS (tpos) = CHAR_TO_BYTE (CHARPOS (tpos)); 3214 BYTEPOS (tpos) = CHAR_TO_BYTE (CHARPOS (tpos));
3238 if (CHARPOS (tpos) >= eob)
3239 break;
3240 spec = Fget_char_property (pos, Qdisplay, object); 3215 spec = Fget_char_property (pos, Qdisplay, object);
3241 if (!STRINGP (object)) 3216 if (!STRINGP (object))
3242 bufpos = CHARPOS (tpos); 3217 bufpos = CHARPOS (tpos);
@@ -3244,8 +3219,6 @@ compute_display_string_pos (struct text_pos *position,
3244 || !handle_display_spec (NULL, spec, object, Qnil, &tpos, bufpos, 3219 || !handle_display_spec (NULL, spec, object, Qnil, &tpos, bufpos,
3245 frame_window_p)); 3220 frame_window_p));
3246 3221
3247 if (!STRINGP (object))
3248 cached_disp_pos = CHARPOS (tpos);
3249 return CHARPOS (tpos); 3222 return CHARPOS (tpos);
3250} 3223}
3251 3224
@@ -5494,6 +5467,9 @@ back_to_previous_line_start (struct it *it)
5494 continuously over the text). Otherwise, don't change the value 5467 continuously over the text). Otherwise, don't change the value
5495 of *SKIPPED_P. 5468 of *SKIPPED_P.
5496 5469
5470 If BIDI_IT_PREV is non-NULL, store into it the state of the bidi
5471 iterator on the newline, if it was found.
5472
5497 Newlines may come from buffer text, overlay strings, or strings 5473 Newlines may come from buffer text, overlay strings, or strings
5498 displayed via the `display' property. That's the reason we can't 5474 displayed via the `display' property. That's the reason we can't
5499 simply use find_next_newline_no_quit. 5475 simply use find_next_newline_no_quit.
@@ -5506,7 +5482,8 @@ back_to_previous_line_start (struct it *it)
5506 leads to wrong cursor motion. */ 5482 leads to wrong cursor motion. */
5507 5483
5508static int 5484static int
5509forward_to_next_line_start (struct it *it, int *skipped_p) 5485forward_to_next_line_start (struct it *it, int *skipped_p,
5486 struct bidi_it *bidi_it_prev)
5510{ 5487{
5511 EMACS_INT old_selective; 5488 EMACS_INT old_selective;
5512 int newline_found_p, n; 5489 int newline_found_p, n;
@@ -5518,6 +5495,8 @@ forward_to_next_line_start (struct it *it, int *skipped_p)
5518 && it->c == '\n' 5495 && it->c == '\n'
5519 && CHARPOS (it->position) == IT_CHARPOS (*it)) 5496 && CHARPOS (it->position) == IT_CHARPOS (*it))
5520 { 5497 {
5498 if (it->bidi_p && bidi_it_prev)
5499 *bidi_it_prev = it->bidi_it;
5521 set_iterator_to_next (it, 0); 5500 set_iterator_to_next (it, 0);
5522 it->c = 0; 5501 it->c = 0;
5523 return 1; 5502 return 1;
@@ -5539,6 +5518,8 @@ forward_to_next_line_start (struct it *it, int *skipped_p)
5539 if (!get_next_display_element (it)) 5518 if (!get_next_display_element (it))
5540 return 0; 5519 return 0;
5541 newline_found_p = it->what == IT_CHARACTER && it->c == '\n'; 5520 newline_found_p = it->what == IT_CHARACTER && it->c == '\n';
5521 if (newline_found_p && it->bidi_p && bidi_it_prev)
5522 *bidi_it_prev = it->bidi_it;
5542 set_iterator_to_next (it, 0); 5523 set_iterator_to_next (it, 0);
5543 } 5524 }
5544 5525
@@ -5573,6 +5554,8 @@ forward_to_next_line_start (struct it *it, int *skipped_p)
5573 && !newline_found_p) 5554 && !newline_found_p)
5574 { 5555 {
5575 newline_found_p = ITERATOR_AT_END_OF_LINE_P (it); 5556 newline_found_p = ITERATOR_AT_END_OF_LINE_P (it);
5557 if (newline_found_p && it->bidi_p && bidi_it_prev)
5558 *bidi_it_prev = it->bidi_it;
5576 set_iterator_to_next (it, 0); 5559 set_iterator_to_next (it, 0);
5577 } 5560 }
5578 } 5561 }
@@ -5696,8 +5679,9 @@ static void
5696reseat_at_next_visible_line_start (struct it *it, int on_newline_p) 5679reseat_at_next_visible_line_start (struct it *it, int on_newline_p)
5697{ 5680{
5698 int newline_found_p, skipped_p = 0; 5681 int newline_found_p, skipped_p = 0;
5682 struct bidi_it bidi_it_prev;
5699 5683
5700 newline_found_p = forward_to_next_line_start (it, &skipped_p); 5684 newline_found_p = forward_to_next_line_start (it, &skipped_p, &bidi_it_prev);
5701 5685
5702 /* Skip over lines that are invisible because they are indented 5686 /* Skip over lines that are invisible because they are indented
5703 more than the value of IT->selective. */ 5687 more than the value of IT->selective. */
@@ -5708,7 +5692,8 @@ reseat_at_next_visible_line_start (struct it *it, int on_newline_p)
5708 { 5692 {
5709 xassert (IT_BYTEPOS (*it) == BEGV 5693 xassert (IT_BYTEPOS (*it) == BEGV
5710 || FETCH_BYTE (IT_BYTEPOS (*it) - 1) == '\n'); 5694 || FETCH_BYTE (IT_BYTEPOS (*it) - 1) == '\n');
5711 newline_found_p = forward_to_next_line_start (it, &skipped_p); 5695 newline_found_p =
5696 forward_to_next_line_start (it, &skipped_p, &bidi_it_prev);
5712 } 5697 }
5713 5698
5714 /* Position on the newline if that's what's requested. */ 5699 /* Position on the newline if that's what's requested. */
@@ -5724,11 +5709,14 @@ reseat_at_next_visible_line_start (struct it *it, int on_newline_p)
5724 --IT_STRING_BYTEPOS (*it); 5709 --IT_STRING_BYTEPOS (*it);
5725 } 5710 }
5726 else 5711 else
5727 /* Setting this flag will cause 5712 {
5728 bidi_move_to_visually_next not to advance, but 5713 /* We need to restore the bidi iterator to the state
5729 instead deliver the current character (newline), 5714 it had on the newline, and resync the IT's
5730 which is what the ON_NEWLINE_P flag wants. */ 5715 position with that. */
5731 it->bidi_it.first_elt = 1; 5716 it->bidi_it = bidi_it_prev;
5717 IT_STRING_CHARPOS (*it) = it->bidi_it.charpos;
5718 IT_STRING_BYTEPOS (*it) = it->bidi_it.bytepos;
5719 }
5732 } 5720 }
5733 } 5721 }
5734 else if (IT_CHARPOS (*it) > BEGV) 5722 else if (IT_CHARPOS (*it) > BEGV)
@@ -5738,9 +5726,14 @@ reseat_at_next_visible_line_start (struct it *it, int on_newline_p)
5738 --IT_CHARPOS (*it); 5726 --IT_CHARPOS (*it);
5739 --IT_BYTEPOS (*it); 5727 --IT_BYTEPOS (*it);
5740 } 5728 }
5741 /* With bidi iteration, the call to `reseat' will cause 5729 else
5742 bidi_move_to_visually_next deliver the current character, 5730 {
5743 the newline, instead of advancing. */ 5731 /* We need to restore the bidi iterator to the state it
5732 had on the newline and resync IT with that. */
5733 it->bidi_it = bidi_it_prev;
5734 IT_CHARPOS (*it) = it->bidi_it.charpos;
5735 IT_BYTEPOS (*it) = it->bidi_it.bytepos;
5736 }
5744 reseat (it, it->current.pos, 0); 5737 reseat (it, it->current.pos, 0);
5745 } 5738 }
5746 } 5739 }