changeset 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 8d5d518bafa5
children 69a4a0370a0b
files src/xdisp.c
diffstat 1 files changed, 63 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/src/xdisp.c	Sat Oct 29 19:40:49 2005 +0000
+++ b/src/xdisp.c	Sat Oct 29 19:43:46 2005 +0000
@@ -3176,6 +3176,9 @@
   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 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 @@
   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 @@
   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 @@
 	 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 @@
     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 @@
     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 @@
   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 @@
 	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 @@
 		aelt = Fassoc (elt, mode_line_proptrans_alist);
 		if (! NILP (aelt) && !NILP (Fequal (props, XCDR (aelt))))
 		  {
+		    /* AELT is what we want.  Move it to the front
+		       without consing.  */
+		    elt = XCAR (aelt);
 		    mode_line_proptrans_alist
-		      = Fcons (aelt, Fdelq (aelt, mode_line_proptrans_alist));
-		    elt = XCAR (aelt);
+		      = 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 @@
     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 @@
     case 'e':
 #ifndef SYSTEM_MALLOC
       {
-	extern char *spare_memory;
-	if (spare_memory)
+	if (NILP (Vmemory_full))
 	  return "";
 	else
 	  return "!MEM FULL! ";