diff options
| author | Kim F. Storm | 2005-06-02 12:27:05 +0000 |
|---|---|---|
| committer | Kim F. Storm | 2005-06-02 12:27:05 +0000 |
| commit | d06e384795d5ca4e82c88273847eeb9d01380046 (patch) | |
| tree | 145658ae4bb1001101206efaf346274de851eb72 /src | |
| parent | 0493f7be8a656af1956aa8bd127f277e1ed9b0df (diff) | |
| download | emacs-d06e384795d5ca4e82c88273847eeb9d01380046.tar.gz emacs-d06e384795d5ca4e82c88273847eeb9d01380046.zip | |
(MODE_LINE_NOPROP_LEN): New macro.
(x_consider_frame_title, Fformat_mode_line): Save offset into
mode_line_noprop_buf rather than pointer, in case buffer is relocated.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xdisp.c | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/src/xdisp.c b/src/xdisp.c index 29fdbab5d78..63af22d9112 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -8173,6 +8173,9 @@ static char *mode_line_noprop_buf; | |||
| 8173 | static char *mode_line_noprop_buf_end; | 8173 | static char *mode_line_noprop_buf_end; |
| 8174 | static char *mode_line_noprop_ptr; | 8174 | static char *mode_line_noprop_ptr; |
| 8175 | 8175 | ||
| 8176 | #define MODE_LINE_NOPROP_LEN(start) \ | ||
| 8177 | ((mode_line_noprop_ptr - mode_line_noprop_buf) - start) | ||
| 8178 | |||
| 8176 | static enum { | 8179 | static enum { |
| 8177 | MODE_LINE_DISPLAY = 0, | 8180 | MODE_LINE_DISPLAY = 0, |
| 8178 | MODE_LINE_TITLE, | 8181 | MODE_LINE_TITLE, |
| @@ -8212,7 +8215,7 @@ format_mode_line_unwind_data (obuf) | |||
| 8212 | vector = Fmake_vector (make_number (7), Qnil); | 8215 | vector = Fmake_vector (make_number (7), Qnil); |
| 8213 | 8216 | ||
| 8214 | AREF (vector, 0) = make_number (mode_line_target); | 8217 | AREF (vector, 0) = make_number (mode_line_target); |
| 8215 | AREF (vector, 1) = make_number (mode_line_noprop_ptr - mode_line_noprop_buf); | 8218 | AREF (vector, 1) = make_number (MODE_LINE_NOPROP_LEN (0)); |
| 8216 | AREF (vector, 2) = mode_line_string_list; | 8219 | AREF (vector, 2) = mode_line_string_list; |
| 8217 | AREF (vector, 3) = mode_line_proptrans_alist; | 8220 | AREF (vector, 3) = mode_line_proptrans_alist; |
| 8218 | AREF (vector, 4) = mode_line_string_face; | 8221 | AREF (vector, 4) = mode_line_string_face; |
| @@ -8263,7 +8266,7 @@ store_mode_line_noprop_char (c) | |||
| 8263 | double the buffer's size. */ | 8266 | double the buffer's size. */ |
| 8264 | if (mode_line_noprop_ptr == mode_line_noprop_buf_end) | 8267 | if (mode_line_noprop_ptr == mode_line_noprop_buf_end) |
| 8265 | { | 8268 | { |
| 8266 | int len = mode_line_noprop_ptr - mode_line_noprop_buf; | 8269 | int len = MODE_LINE_NOPROP_LEN (0); |
| 8267 | int new_size = 2 * len * sizeof *mode_line_noprop_buf; | 8270 | int new_size = 2 * len * sizeof *mode_line_noprop_buf; |
| 8268 | mode_line_noprop_buf = (char *) xrealloc (mode_line_noprop_buf, new_size); | 8271 | mode_line_noprop_buf = (char *) xrealloc (mode_line_noprop_buf, new_size); |
| 8269 | mode_line_noprop_buf_end = mode_line_noprop_buf + new_size; | 8272 | mode_line_noprop_buf_end = mode_line_noprop_buf + new_size; |
| @@ -8330,7 +8333,8 @@ x_consider_frame_title (frame) | |||
| 8330 | /* Do we have more than one visible frame on this X display? */ | 8333 | /* Do we have more than one visible frame on this X display? */ |
| 8331 | Lisp_Object tail; | 8334 | Lisp_Object tail; |
| 8332 | Lisp_Object fmt; | 8335 | Lisp_Object fmt; |
| 8333 | char *title_start; | 8336 | int title_start; |
| 8337 | char *title; | ||
| 8334 | int len; | 8338 | int len; |
| 8335 | struct it it; | 8339 | struct it it; |
| 8336 | int count = SPECPDL_INDEX (); | 8340 | int count = SPECPDL_INDEX (); |
| @@ -8361,12 +8365,12 @@ x_consider_frame_title (frame) | |||
| 8361 | fmt = FRAME_ICONIFIED_P (f) ? Vicon_title_format : Vframe_title_format; | 8365 | fmt = FRAME_ICONIFIED_P (f) ? Vicon_title_format : Vframe_title_format; |
| 8362 | 8366 | ||
| 8363 | mode_line_target = MODE_LINE_TITLE; | 8367 | mode_line_target = MODE_LINE_TITLE; |
| 8364 | title_start = mode_line_noprop_ptr; | 8368 | title_start = MODE_LINE_NOPROP_LEN (0); |
| 8365 | init_iterator (&it, XWINDOW (f->selected_window), -1, -1, | 8369 | init_iterator (&it, XWINDOW (f->selected_window), -1, -1, |
| 8366 | NULL, DEFAULT_FACE_ID); | 8370 | NULL, DEFAULT_FACE_ID); |
| 8367 | display_mode_element (&it, 0, -1, -1, fmt, Qnil, 0); | 8371 | display_mode_element (&it, 0, -1, -1, fmt, Qnil, 0); |
| 8368 | len = mode_line_noprop_ptr - title_start; | 8372 | len = MODE_LINE_NOPROP_LEN (title_start); |
| 8369 | 8373 | title = mode_line_noprop_buf + title_start; | |
| 8370 | unbind_to (count, Qnil); | 8374 | unbind_to (count, Qnil); |
| 8371 | 8375 | ||
| 8372 | /* Set the title only if it's changed. This avoids consing in | 8376 | /* Set the title only if it's changed. This avoids consing in |
| @@ -8376,8 +8380,8 @@ x_consider_frame_title (frame) | |||
| 8376 | higher level than this.) */ | 8380 | higher level than this.) */ |
| 8377 | if (! STRINGP (f->name) | 8381 | if (! STRINGP (f->name) |
| 8378 | || SBYTES (f->name) != len | 8382 | || SBYTES (f->name) != len |
| 8379 | || bcmp (title_start, SDATA (f->name), len) != 0) | 8383 | || bcmp (title, SDATA (f->name), len) != 0) |
| 8380 | x_implicitly_set_name (f, make_string (title_start, len), Qnil); | 8384 | x_implicitly_set_name (f, make_string (title, len), Qnil); |
| 8381 | } | 8385 | } |
| 8382 | } | 8386 | } |
| 8383 | 8387 | ||
| @@ -16300,7 +16304,7 @@ are the selected window and the window's buffer). */) | |||
| 16300 | int no_props = INTEGERP (face); | 16304 | int no_props = INTEGERP (face); |
| 16301 | int count = SPECPDL_INDEX (); | 16305 | int count = SPECPDL_INDEX (); |
| 16302 | Lisp_Object str; | 16306 | Lisp_Object str; |
| 16303 | char *string_start = NULL; | 16307 | int string_start = 0; |
| 16304 | 16308 | ||
| 16305 | if (NILP (window)) | 16309 | if (NILP (window)) |
| 16306 | window = selected_window; | 16310 | window = selected_window; |
| @@ -16343,7 +16347,7 @@ are the selected window and the window's buffer). */) | |||
| 16343 | mode_line_target = MODE_LINE_NOPROP; | 16347 | mode_line_target = MODE_LINE_NOPROP; |
| 16344 | mode_line_string_face_prop = Qnil; | 16348 | mode_line_string_face_prop = Qnil; |
| 16345 | mode_line_string_list = Qnil; | 16349 | mode_line_string_list = Qnil; |
| 16346 | string_start = mode_line_noprop_ptr; | 16350 | string_start = MODE_LINE_NOPROP_LEN (0); |
| 16347 | } | 16351 | } |
| 16348 | else | 16352 | else |
| 16349 | { | 16353 | { |
| @@ -16352,8 +16356,6 @@ are the selected window and the window's buffer). */) | |||
| 16352 | mode_line_string_face = face; | 16356 | mode_line_string_face = face; |
| 16353 | mode_line_string_face_prop | 16357 | mode_line_string_face_prop |
| 16354 | = (NILP (face) ? Qnil : Fcons (Qface, Fcons (face, Qnil))); | 16358 | = (NILP (face) ? Qnil : Fcons (Qface, Fcons (face, Qnil))); |
| 16355 | |||
| 16356 | string_start = NULL; | ||
| 16357 | } | 16359 | } |
| 16358 | 16360 | ||
| 16359 | push_frame_kboard (it.f); | 16361 | push_frame_kboard (it.f); |
| @@ -16362,8 +16364,8 @@ are the selected window and the window's buffer). */) | |||
| 16362 | 16364 | ||
| 16363 | if (no_props) | 16365 | if (no_props) |
| 16364 | { | 16366 | { |
| 16365 | len = mode_line_noprop_ptr - string_start; | 16367 | len = MODE_LINE_NOPROP_LEN (string_start); |
| 16366 | str = make_string (string_start, len); | 16368 | str = make_string (mode_line_noprop_buf + string_start, len); |
| 16367 | } | 16369 | } |
| 16368 | else | 16370 | else |
| 16369 | { | 16371 | { |