From f5b8d5f2636a87337e5174ffcd3fe1e256d97e42 Mon Sep 17 00:00:00 2001 From: "Richard M. Stallman" Date: Sat, 29 Oct 2005 19:44:25 +0000 Subject: [PATCH] (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. --- src/ChangeLog | 38 ++++++++++++++++++++++++++ src/xdisp.c | 75 ++++++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 101 insertions(+), 12 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 5df0e83b364..c9db3f69cf2 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,41 @@ +2005-10-29 Richard M. Stallman + + * xdisp.c (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. + + * lisp.h (memory_full_cons_threshold): Declared. + (internal_lisp_condition_case): Declared. + + * alloc.c (syms_of_alloc) : Doc fix. + (Fmemory_full_p): Function deleted. + (syms_of_alloc): Don't defsubr it. + (memory_full_cons_threshold): New variable. + (spare_memory): Now a vector of 7 elts. + (buffer_memory_full): Don't set Vmemory_full here. + (xfree): Don't try to refill here. + (emacs_blocked_free): Record BYTES_USED in local var. + (memory_full): Now free all the slots in spare_memory. + (refill_memory_reserve): Allocate each slot in spare_memory. + (init_alloc_once): Call refill_memory_reserve. + + * keyboard.c (command_loop_1): Don't set Vmemory_full here. + + * eval.c (internal_lisp_condition_case): New function. + (Fcondition_case): Use internal_lisp_condition_case. + (Feval): Test Vmemory_full and memory_full_cons_threshold. + (Ffuncall): Likewise. + + * bytecode.c (Fbyte_code): Use internal_lisp_condition_case. + 2005-10-29 Stefan Monnier * syntax.c (Fparse_partial_sexp): Fix docstring. diff --git a/src/xdisp.c b/src/xdisp.c index 973528bebf5..88090f7b212 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -3176,6 +3176,9 @@ handle_fontified_prop (it) Lisp_Object prop, pos; enum prop_handled handled = HANDLED_NORMALLY; + if (!NILP (Vmemory_full)) + return handled; + /* Get the value of the `fontified' property at IT's current buffer position. (The `fontified' property doesn't have a special meaning in strings.) If the value is nil, call functions from @@ -8616,7 +8619,7 @@ static Lisp_Object mode_line_string_face_prop; static Lisp_Object Vmode_line_unwind_vector; static Lisp_Object -format_mode_line_unwind_data (obuf) +format_mode_line_unwind_data (obuf, save_proptrans) struct buffer *obuf; { Lisp_Object vector; @@ -8632,7 +8635,7 @@ format_mode_line_unwind_data (obuf) AREF (vector, 0) = make_number (mode_line_target); AREF (vector, 1) = make_number (MODE_LINE_NOPROP_LEN (0)); AREF (vector, 2) = mode_line_string_list; - AREF (vector, 3) = mode_line_proptrans_alist; + AREF (vector, 3) = (save_proptrans ? mode_line_proptrans_alist : Qt); AREF (vector, 4) = mode_line_string_face; AREF (vector, 5) = mode_line_string_face_prop; @@ -8651,7 +8654,8 @@ unwind_format_mode_line (vector) mode_line_target = XINT (AREF (vector, 0)); mode_line_noprop_ptr = mode_line_noprop_buf + XINT (AREF (vector, 1)); mode_line_string_list = AREF (vector, 2); - mode_line_proptrans_alist = AREF (vector, 3); + if (! EQ (AREF (vector, 3), Qt)) + mode_line_proptrans_alist = AREF (vector, 3); mode_line_string_face = AREF (vector, 4); mode_line_string_face_prop = AREF (vector, 5); @@ -8774,7 +8778,7 @@ x_consider_frame_title (frame) mode_line_target so that display_mode_element will output into mode_line_noprop_buf; then display the title. */ record_unwind_protect (unwind_format_mode_line, - format_mode_line_unwind_data (current_buffer)); + format_mode_line_unwind_data (current_buffer, 0)); set_buffer_internal_1 (XBUFFER (XWINDOW (f->selected_window)->buffer)); fmt = FRAME_ICONIFIED_P (f) ? Vicon_title_format : Vframe_title_format; @@ -10571,7 +10575,8 @@ redisplay_internal (preserve_echo_area) clear_garbaged_frames (); /* Build menubar and tool-bar items. */ - prepare_menu_bars (); + if (NILP (Vmemory_full)) + prepare_menu_bars (); if (windows_or_buffers_changed) update_mode_lines++; @@ -16159,7 +16164,7 @@ display_mode_line (w, face_id, format) it.base_face_id = it.face_id = DEFAULT_FACE_ID; record_unwind_protect (unwind_format_mode_line, - format_mode_line_unwind_data (NULL)); + format_mode_line_unwind_data (NULL, 0)); mode_line_target = MODE_LINE_DISPLAY; @@ -16194,6 +16199,44 @@ display_mode_line (w, face_id, format) return it.glyph_row->height; } +/* Move element ELT in LIST to the front of LIST. + Return the updated list. */ + +static Lisp_Object +move_elt_to_front (elt, list) + Lisp_Object elt, list; +{ + register Lisp_Object tail, prev; + register Lisp_Object tem; + + tail = list; + prev = Qnil; + while (CONSP (tail)) + { + tem = XCAR (tail); + + if (EQ (elt, tem)) + { + /* Splice out the link TAIL. */ + if (NILP (prev)) + list = XCDR (tail); + else + Fsetcdr (prev, XCDR (tail)); + + /* Now make it the first. */ + Fsetcdr (tail, list); + return tail; + } + else + prev = tail; + tail = XCDR (tail); + QUIT; + } + + /* Not found--return unchanged LIST. */ + return list; +} + /* Contribute ELT to the mode line for window IT->w. How it translates into text depends on its data type. @@ -16243,7 +16286,8 @@ display_mode_element (it, depth, field_width, precision, elt, props, risky) unsigned char c; int offset = 0; - if (!NILP (props) || risky) + if (SCHARS (elt) > 0 + && (!NILP (props) || risky)) { Lisp_Object oprops, aelt; oprops = Ftext_properties_at (make_number (0), elt); @@ -16274,14 +16318,22 @@ display_mode_element (it, depth, field_width, precision, elt, props, risky) aelt = Fassoc (elt, mode_line_proptrans_alist); if (! NILP (aelt) && !NILP (Fequal (props, XCDR (aelt)))) { - mode_line_proptrans_alist - = Fcons (aelt, Fdelq (aelt, mode_line_proptrans_alist)); + /* AELT is what we want. Move it to the front + without consing. */ elt = XCAR (aelt); + mode_line_proptrans_alist + = move_elt_to_front (aelt, mode_line_proptrans_alist); } else { Lisp_Object tem; + /* If AELT has the wrong props, it is useless. + so get rid of it. */ + if (! NILP (aelt)) + mode_line_proptrans_alist + = Fdelq (aelt, mode_line_proptrans_alist); + elt = Fcopy_sequence (elt); Fset_text_properties (make_number (0), Flength (elt), props, elt); @@ -16807,7 +16859,7 @@ are the selected window and the window's buffer). */) old_buffer = current_buffer; record_unwind_protect (unwind_format_mode_line, - format_mode_line_unwind_data (old_buffer)); + format_mode_line_unwind_data (old_buffer, 1)); if (old_buffer) set_buffer_internal_1 (XBUFFER (buffer)); @@ -17195,8 +17247,7 @@ decode_mode_spec (w, c, field_width, precision, multibyte) case 'e': #ifndef SYSTEM_MALLOC { - extern char *spare_memory; - if (spare_memory) + if (NILP (Vmemory_full)) return ""; else return "!MEM FULL! "; -- 2.39.5