+2005-10-29 Richard M. Stallman <rms@gnu.org>
+
+ * 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) <memory-full>: 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 <monnier@iro.umontreal.ca>
* syntax.c (Fparse_partial_sexp): Fix docstring.
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
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;
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;
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);
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;
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++;
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;
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.
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);
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);
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));
case 'e':
#ifndef SYSTEM_MALLOC
{
- extern char *spare_memory;
- if (spare_memory)
+ if (NILP (Vmemory_full))
return "";
else
return "!MEM FULL! ";