changeset 25018:890e8042db8f

(Fmessage): Use message3. (Fcurrent_message): If echo_area_message is set, return a substring of that string. (Fformat): Add text properties to the result string from properties of the format string and properties of string arguments. (make_buffer_string_both) [PROMPT_IN_BUFFER]: Prevent start > end. (make_buffer_string) [PROMPT_IN_BUFFER]: If start position is less than mini-buffer prompt width, use the prompt width as start. (make_buffer_string) [PROMPT_IN_BUFFER): Add prompt length to start position.
author Gerd Moellmann <gerd@gnu.org>
date Wed, 21 Jul 1999 21:43:52 +0000
parents 4a142fb92f94
children c5eb87f3571e
files src/editfns.c
diffstat 1 files changed, 70 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/src/editfns.c	Wed Jul 21 21:43:52 1999 +0000
+++ b/src/editfns.c	Wed Jul 21 21:43:52 1999 +0000
@@ -1606,6 +1606,15 @@
 {
   Lisp_Object result, tem, tem1;
 
+#if !NO_PROMPT_IN_BUFFER
+  if (INTEGERP (current_buffer->minibuffer_prompt_length))
+    {
+      int len = XFASTINT (current_buffer->minibuffer_prompt_length);
+      start = min (end, max (len, start));
+      start_byte = CHAR_TO_BYTE (start);
+    }
+#endif
+
   if (start < GPT && GPT < end)
     move_gap (start);
 
@@ -2339,20 +2348,7 @@
     {
       register Lisp_Object val;
       val = Fformat (nargs, args);
-      /* Copy the data so that it won't move when we GC.  */
-      if (! message_text)
-	{
-	  message_text = (char *)xmalloc (80);
-	  message_length = 80;
-	}
-      if (STRING_BYTES (XSTRING (val)) > message_length)
-	{
-	  message_length = STRING_BYTES (XSTRING (val));
-	  message_text = (char *)xrealloc (message_text, message_length);
-	}
-      bcopy (XSTRING (val)->data, message_text, STRING_BYTES (XSTRING (val)));
-      message2 (message_text, STRING_BYTES (XSTRING (val)),
-		STRING_MULTIBYTE (val));
+      message3 (val, STRING_BYTES (XSTRING (val)), STRING_MULTIBYTE (val));
       return val;
     }
 }
@@ -2436,6 +2432,9 @@
   "Return the string currently displayed in the echo area, or nil if none.")
   ()
 {
+  if (STRINGP (echo_area_message))
+    return make_string (XSTRING (echo_area_message)->data,
+			echo_area_glyphs_length);
   return (echo_area_glyphs
 	  ? make_string (echo_area_glyphs, echo_area_glyphs_length)
 	  : Qnil);
@@ -2485,6 +2484,10 @@
   unsigned char *this_format;
   int longest_format;
   Lisp_Object val;
+  struct info
+  {
+    int start, end;
+  } *info = 0;
 
   extern char *index ();
 
@@ -2679,6 +2682,7 @@
 	      int padding, nbytes;
 	      int width = strwidth (XSTRING (args[n])->data,
 				    STRING_BYTES (XSTRING (args[n])));
+	      int start = nchars;
 
 	      /* If spec requires it, pad on right with spaces.  */
 	      padding = minlen - width;
@@ -2707,6 +2711,21 @@
 		    *p++ = ' ';
 		    nchars++;
 		  }
+
+	      /* If this argument has text properties, record where
+		 in the result string it appears.  */
+	      if (XSTRING (args[n])->intervals)
+		{
+		  if (!info)
+		    {
+		      int nbytes = nargs * sizeof *info;
+		      info = (struct info *) alloca (nbytes);
+		      bzero (info, nbytes);
+		    }
+		  
+		  info[n].start = start;
+		  info[n].end = nchars;
+		}
 	    }
 	  else if (INTEGERP (args[n]) || FLOATP (args[n]))
 	    {
@@ -2764,6 +2783,43 @@
   if (total >= 1000)
     xfree (buf);
 
+  /* If the format string has text properties, or any of the string
+     arguments has text properties, set up text properties of the
+     result string.  */
+  
+  if (XSTRING (args[0])->intervals || info)
+    {
+      Lisp_Object len, new_len, props;
+      struct gcpro gcpro1;
+      
+      /* Add text properties from the format string.  */
+      len = make_number (XSTRING (args[0])->size);
+      props = text_property_list (args[0], make_number (0), len, Qnil);
+      GCPRO1 (props);
+      
+      if (CONSP (props))
+	{
+	  new_len = make_number (XSTRING (val)->size);
+	  extend_property_ranges (props, len, new_len);
+	  add_text_properties_from_list (val, props, make_number (0));
+	}
+
+      /* Add text properties from arguments.  */
+      if (info)
+	for (n = 1; n < nargs; ++n)
+	  if (info[n].end)
+	    {
+	      len = make_number (XSTRING (args[n])->size);
+	      new_len = make_number (info[n].end - info[n].start);
+	      props = text_property_list (args[n], make_number (0), len, Qnil);
+	      extend_property_ranges (props, len, new_len);
+	      add_text_properties_from_list (val, props,
+					     make_number (info[n].start));
+	    }
+
+      UNGCPRO;
+    }
+
   return val;
 }