Mercurial > emacs
comparison src/xdisp.c @ 66532:c5614dc43269
(handle_fontified_prop): Do nothing if memory full.
(format_mode_line_unwind_data): New arg SAVE_PROPTRANS
controls whether to save and restore mode_line_proptrans_alist.
Callers changed.
(unwind_format_mode_line): Work with that feature.
(redisplay_internal): Don't call prepare_menu_bars if memory full.
(move_elt_to_front): New function.
(display_mode_element): Use move_elt_to_front.
Don't bother munging text props on a null string.
Delete obsolete elts from mode_line_proptrans_alist.
(decode_mode_spec): Test Vmemory_full, not spare_memory.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sat, 29 Oct 2005 19:43:46 +0000 |
parents | 737938f4c826 |
children | f9d0901bbb61 |
comparison
equal
deleted
inserted
replaced
66531:8d5d518bafa5 | 66532:c5614dc43269 |
---|---|
3174 struct it *it; | 3174 struct it *it; |
3175 { | 3175 { |
3176 Lisp_Object prop, pos; | 3176 Lisp_Object prop, pos; |
3177 enum prop_handled handled = HANDLED_NORMALLY; | 3177 enum prop_handled handled = HANDLED_NORMALLY; |
3178 | 3178 |
3179 if (!NILP (Vmemory_full)) | |
3180 return handled; | |
3181 | |
3179 /* Get the value of the `fontified' property at IT's current buffer | 3182 /* Get the value of the `fontified' property at IT's current buffer |
3180 position. (The `fontified' property doesn't have a special | 3183 position. (The `fontified' property doesn't have a special |
3181 meaning in strings.) If the value is nil, call functions from | 3184 meaning in strings.) If the value is nil, call functions from |
3182 Qfontification_functions. */ | 3185 Qfontification_functions. */ |
3183 if (!STRINGP (it->string) | 3186 if (!STRINGP (it->string) |
8614 /* Unwind data for mode line strings */ | 8617 /* Unwind data for mode line strings */ |
8615 | 8618 |
8616 static Lisp_Object Vmode_line_unwind_vector; | 8619 static Lisp_Object Vmode_line_unwind_vector; |
8617 | 8620 |
8618 static Lisp_Object | 8621 static Lisp_Object |
8619 format_mode_line_unwind_data (obuf) | 8622 format_mode_line_unwind_data (obuf, save_proptrans) |
8620 struct buffer *obuf; | 8623 struct buffer *obuf; |
8621 { | 8624 { |
8622 Lisp_Object vector; | 8625 Lisp_Object vector; |
8623 | 8626 |
8624 /* Reduce consing by keeping one vector in | 8627 /* Reduce consing by keeping one vector in |
8630 vector = Fmake_vector (make_number (7), Qnil); | 8633 vector = Fmake_vector (make_number (7), Qnil); |
8631 | 8634 |
8632 AREF (vector, 0) = make_number (mode_line_target); | 8635 AREF (vector, 0) = make_number (mode_line_target); |
8633 AREF (vector, 1) = make_number (MODE_LINE_NOPROP_LEN (0)); | 8636 AREF (vector, 1) = make_number (MODE_LINE_NOPROP_LEN (0)); |
8634 AREF (vector, 2) = mode_line_string_list; | 8637 AREF (vector, 2) = mode_line_string_list; |
8635 AREF (vector, 3) = mode_line_proptrans_alist; | 8638 AREF (vector, 3) = (save_proptrans ? mode_line_proptrans_alist : Qt); |
8636 AREF (vector, 4) = mode_line_string_face; | 8639 AREF (vector, 4) = mode_line_string_face; |
8637 AREF (vector, 5) = mode_line_string_face_prop; | 8640 AREF (vector, 5) = mode_line_string_face_prop; |
8638 | 8641 |
8639 if (obuf) | 8642 if (obuf) |
8640 XSETBUFFER (AREF (vector, 6), obuf); | 8643 XSETBUFFER (AREF (vector, 6), obuf); |
8649 Lisp_Object vector; | 8652 Lisp_Object vector; |
8650 { | 8653 { |
8651 mode_line_target = XINT (AREF (vector, 0)); | 8654 mode_line_target = XINT (AREF (vector, 0)); |
8652 mode_line_noprop_ptr = mode_line_noprop_buf + XINT (AREF (vector, 1)); | 8655 mode_line_noprop_ptr = mode_line_noprop_buf + XINT (AREF (vector, 1)); |
8653 mode_line_string_list = AREF (vector, 2); | 8656 mode_line_string_list = AREF (vector, 2); |
8654 mode_line_proptrans_alist = AREF (vector, 3); | 8657 if (! EQ (AREF (vector, 3), Qt)) |
8658 mode_line_proptrans_alist = AREF (vector, 3); | |
8655 mode_line_string_face = AREF (vector, 4); | 8659 mode_line_string_face = AREF (vector, 4); |
8656 mode_line_string_face_prop = AREF (vector, 5); | 8660 mode_line_string_face_prop = AREF (vector, 5); |
8657 | 8661 |
8658 if (!NILP (AREF (vector, 6))) | 8662 if (!NILP (AREF (vector, 6))) |
8659 { | 8663 { |
8772 | 8776 |
8773 /* Switch to the buffer of selected window of the frame. Set up | 8777 /* Switch to the buffer of selected window of the frame. Set up |
8774 mode_line_target so that display_mode_element will output into | 8778 mode_line_target so that display_mode_element will output into |
8775 mode_line_noprop_buf; then display the title. */ | 8779 mode_line_noprop_buf; then display the title. */ |
8776 record_unwind_protect (unwind_format_mode_line, | 8780 record_unwind_protect (unwind_format_mode_line, |
8777 format_mode_line_unwind_data (current_buffer)); | 8781 format_mode_line_unwind_data (current_buffer, 0)); |
8778 | 8782 |
8779 set_buffer_internal_1 (XBUFFER (XWINDOW (f->selected_window)->buffer)); | 8783 set_buffer_internal_1 (XBUFFER (XWINDOW (f->selected_window)->buffer)); |
8780 fmt = FRAME_ICONIFIED_P (f) ? Vicon_title_format : Vframe_title_format; | 8784 fmt = FRAME_ICONIFIED_P (f) ? Vicon_title_format : Vframe_title_format; |
8781 | 8785 |
8782 mode_line_target = MODE_LINE_TITLE; | 8786 mode_line_target = MODE_LINE_TITLE; |
10569 /* Clear frames marked as garbaged. */ | 10573 /* Clear frames marked as garbaged. */ |
10570 if (frame_garbaged) | 10574 if (frame_garbaged) |
10571 clear_garbaged_frames (); | 10575 clear_garbaged_frames (); |
10572 | 10576 |
10573 /* Build menubar and tool-bar items. */ | 10577 /* Build menubar and tool-bar items. */ |
10574 prepare_menu_bars (); | 10578 if (NILP (Vmemory_full)) |
10579 prepare_menu_bars (); | |
10575 | 10580 |
10576 if (windows_or_buffers_changed) | 10581 if (windows_or_buffers_changed) |
10577 update_mode_lines++; | 10582 update_mode_lines++; |
10578 | 10583 |
10579 /* Detect case that we need to write or remove a star in the mode line. */ | 10584 /* Detect case that we need to write or remove a star in the mode line. */ |
16157 if (! mode_line_inverse_video) | 16162 if (! mode_line_inverse_video) |
16158 /* Force the mode-line to be displayed in the default face. */ | 16163 /* Force the mode-line to be displayed in the default face. */ |
16159 it.base_face_id = it.face_id = DEFAULT_FACE_ID; | 16164 it.base_face_id = it.face_id = DEFAULT_FACE_ID; |
16160 | 16165 |
16161 record_unwind_protect (unwind_format_mode_line, | 16166 record_unwind_protect (unwind_format_mode_line, |
16162 format_mode_line_unwind_data (NULL)); | 16167 format_mode_line_unwind_data (NULL, 0)); |
16163 | 16168 |
16164 mode_line_target = MODE_LINE_DISPLAY; | 16169 mode_line_target = MODE_LINE_DISPLAY; |
16165 | 16170 |
16166 /* Temporarily make frame's keyboard the current kboard so that | 16171 /* Temporarily make frame's keyboard the current kboard so that |
16167 kboard-local variables in the mode_line_format will get the right | 16172 kboard-local variables in the mode_line_format will get the right |
16190 + it.glyph_row->used[TEXT_AREA] - 1); | 16195 + it.glyph_row->used[TEXT_AREA] - 1); |
16191 last->right_box_line_p = 1; | 16196 last->right_box_line_p = 1; |
16192 } | 16197 } |
16193 | 16198 |
16194 return it.glyph_row->height; | 16199 return it.glyph_row->height; |
16200 } | |
16201 | |
16202 /* Move element ELT in LIST to the front of LIST. | |
16203 Return the updated list. */ | |
16204 | |
16205 static Lisp_Object | |
16206 move_elt_to_front (elt, list) | |
16207 Lisp_Object elt, list; | |
16208 { | |
16209 register Lisp_Object tail, prev; | |
16210 register Lisp_Object tem; | |
16211 | |
16212 tail = list; | |
16213 prev = Qnil; | |
16214 while (CONSP (tail)) | |
16215 { | |
16216 tem = XCAR (tail); | |
16217 | |
16218 if (EQ (elt, tem)) | |
16219 { | |
16220 /* Splice out the link TAIL. */ | |
16221 if (NILP (prev)) | |
16222 list = XCDR (tail); | |
16223 else | |
16224 Fsetcdr (prev, XCDR (tail)); | |
16225 | |
16226 /* Now make it the first. */ | |
16227 Fsetcdr (tail, list); | |
16228 return tail; | |
16229 } | |
16230 else | |
16231 prev = tail; | |
16232 tail = XCDR (tail); | |
16233 QUIT; | |
16234 } | |
16235 | |
16236 /* Not found--return unchanged LIST. */ | |
16237 return list; | |
16195 } | 16238 } |
16196 | 16239 |
16197 /* Contribute ELT to the mode line for window IT->w. How it | 16240 /* Contribute ELT to the mode line for window IT->w. How it |
16198 translates into text depends on its data type. | 16241 translates into text depends on its data type. |
16199 | 16242 |
16241 { | 16284 { |
16242 /* A string: output it and check for %-constructs within it. */ | 16285 /* A string: output it and check for %-constructs within it. */ |
16243 unsigned char c; | 16286 unsigned char c; |
16244 int offset = 0; | 16287 int offset = 0; |
16245 | 16288 |
16246 if (!NILP (props) || risky) | 16289 if (SCHARS (elt) > 0 |
16290 && (!NILP (props) || risky)) | |
16247 { | 16291 { |
16248 Lisp_Object oprops, aelt; | 16292 Lisp_Object oprops, aelt; |
16249 oprops = Ftext_properties_at (make_number (0), elt); | 16293 oprops = Ftext_properties_at (make_number (0), elt); |
16250 | 16294 |
16251 /* If the starting string's properties are not what | 16295 /* If the starting string's properties are not what |
16272 } | 16316 } |
16273 | 16317 |
16274 aelt = Fassoc (elt, mode_line_proptrans_alist); | 16318 aelt = Fassoc (elt, mode_line_proptrans_alist); |
16275 if (! NILP (aelt) && !NILP (Fequal (props, XCDR (aelt)))) | 16319 if (! NILP (aelt) && !NILP (Fequal (props, XCDR (aelt)))) |
16276 { | 16320 { |
16321 /* AELT is what we want. Move it to the front | |
16322 without consing. */ | |
16323 elt = XCAR (aelt); | |
16277 mode_line_proptrans_alist | 16324 mode_line_proptrans_alist |
16278 = Fcons (aelt, Fdelq (aelt, mode_line_proptrans_alist)); | 16325 = move_elt_to_front (aelt, mode_line_proptrans_alist); |
16279 elt = XCAR (aelt); | |
16280 } | 16326 } |
16281 else | 16327 else |
16282 { | 16328 { |
16283 Lisp_Object tem; | 16329 Lisp_Object tem; |
16330 | |
16331 /* If AELT has the wrong props, it is useless. | |
16332 so get rid of it. */ | |
16333 if (! NILP (aelt)) | |
16334 mode_line_proptrans_alist | |
16335 = Fdelq (aelt, mode_line_proptrans_alist); | |
16284 | 16336 |
16285 elt = Fcopy_sequence (elt); | 16337 elt = Fcopy_sequence (elt); |
16286 Fset_text_properties (make_number (0), Flength (elt), | 16338 Fset_text_properties (make_number (0), Flength (elt), |
16287 props, elt); | 16339 props, elt); |
16288 /* Add this item to mode_line_proptrans_alist. */ | 16340 /* Add this item to mode_line_proptrans_alist. */ |
16805 | 16857 |
16806 if (XBUFFER (buffer) != current_buffer) | 16858 if (XBUFFER (buffer) != current_buffer) |
16807 old_buffer = current_buffer; | 16859 old_buffer = current_buffer; |
16808 | 16860 |
16809 record_unwind_protect (unwind_format_mode_line, | 16861 record_unwind_protect (unwind_format_mode_line, |
16810 format_mode_line_unwind_data (old_buffer)); | 16862 format_mode_line_unwind_data (old_buffer, 1)); |
16811 | 16863 |
16812 if (old_buffer) | 16864 if (old_buffer) |
16813 set_buffer_internal_1 (XBUFFER (buffer)); | 16865 set_buffer_internal_1 (XBUFFER (buffer)); |
16814 | 16866 |
16815 init_iterator (&it, w, -1, -1, NULL, face_id); | 16867 init_iterator (&it, w, -1, -1, NULL, face_id); |
17193 } | 17245 } |
17194 | 17246 |
17195 case 'e': | 17247 case 'e': |
17196 #ifndef SYSTEM_MALLOC | 17248 #ifndef SYSTEM_MALLOC |
17197 { | 17249 { |
17198 extern char *spare_memory; | 17250 if (NILP (Vmemory_full)) |
17199 if (spare_memory) | |
17200 return ""; | 17251 return ""; |
17201 else | 17252 else |
17202 return "!MEM FULL! "; | 17253 return "!MEM FULL! "; |
17203 } | 17254 } |
17204 #else | 17255 #else |