aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGerd Moellmann1999-07-21 21:43:52 +0000
committerGerd Moellmann1999-07-21 21:43:52 +0000
commit5e6d54931471a67bcd1cc1d44166f0e2430d027f (patch)
treea4f4944b0c93880f0b880abd4fe0f7a3e55e896f /src
parent5010d3b8025ea541f0186deb68bdd629e4d5e963 (diff)
downloademacs-5e6d54931471a67bcd1cc1d44166f0e2430d027f.tar.gz
emacs-5e6d54931471a67bcd1cc1d44166f0e2430d027f.zip
(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.
Diffstat (limited to 'src')
-rw-r--r--src/editfns.c84
1 files changed, 70 insertions, 14 deletions
diff --git a/src/editfns.c b/src/editfns.c
index 0812fb9b87e..bbe6aec0e8a 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -1606,6 +1606,15 @@ make_buffer_string_both (start, start_byte, end, end_byte, props)
1606{ 1606{
1607 Lisp_Object result, tem, tem1; 1607 Lisp_Object result, tem, tem1;
1608 1608
1609#if !NO_PROMPT_IN_BUFFER
1610 if (INTEGERP (current_buffer->minibuffer_prompt_length))
1611 {
1612 int len = XFASTINT (current_buffer->minibuffer_prompt_length);
1613 start = min (end, max (len, start));
1614 start_byte = CHAR_TO_BYTE (start);
1615 }
1616#endif
1617
1609 if (start < GPT && GPT < end) 1618 if (start < GPT && GPT < end)
1610 move_gap (start); 1619 move_gap (start);
1611 1620
@@ -2339,20 +2348,7 @@ minibuffer contents show.")
2339 { 2348 {
2340 register Lisp_Object val; 2349 register Lisp_Object val;
2341 val = Fformat (nargs, args); 2350 val = Fformat (nargs, args);
2342 /* Copy the data so that it won't move when we GC. */ 2351 message3 (val, STRING_BYTES (XSTRING (val)), STRING_MULTIBYTE (val));
2343 if (! message_text)
2344 {
2345 message_text = (char *)xmalloc (80);
2346 message_length = 80;
2347 }
2348 if (STRING_BYTES (XSTRING (val)) > message_length)
2349 {
2350 message_length = STRING_BYTES (XSTRING (val));
2351 message_text = (char *)xrealloc (message_text, message_length);
2352 }
2353 bcopy (XSTRING (val)->data, message_text, STRING_BYTES (XSTRING (val)));
2354 message2 (message_text, STRING_BYTES (XSTRING (val)),
2355 STRING_MULTIBYTE (val));
2356 return val; 2352 return val;
2357 } 2353 }
2358} 2354}
@@ -2436,6 +2432,9 @@ DEFUN ("current-message", Fcurrent_message, Scurrent_message, 0, 0, 0,
2436 "Return the string currently displayed in the echo area, or nil if none.") 2432 "Return the string currently displayed in the echo area, or nil if none.")
2437 () 2433 ()
2438{ 2434{
2435 if (STRINGP (echo_area_message))
2436 return make_string (XSTRING (echo_area_message)->data,
2437 echo_area_glyphs_length);
2439 return (echo_area_glyphs 2438 return (echo_area_glyphs
2440 ? make_string (echo_area_glyphs, echo_area_glyphs_length) 2439 ? make_string (echo_area_glyphs, echo_area_glyphs_length)
2441 : Qnil); 2440 : Qnil);
@@ -2485,6 +2484,10 @@ Use %% to put a single % into the output.")
2485 unsigned char *this_format; 2484 unsigned char *this_format;
2486 int longest_format; 2485 int longest_format;
2487 Lisp_Object val; 2486 Lisp_Object val;
2487 struct info
2488 {
2489 int start, end;
2490 } *info = 0;
2488 2491
2489 extern char *index (); 2492 extern char *index ();
2490 2493
@@ -2679,6 +2682,7 @@ Use %% to put a single % into the output.")
2679 int padding, nbytes; 2682 int padding, nbytes;
2680 int width = strwidth (XSTRING (args[n])->data, 2683 int width = strwidth (XSTRING (args[n])->data,
2681 STRING_BYTES (XSTRING (args[n]))); 2684 STRING_BYTES (XSTRING (args[n])));
2685 int start = nchars;
2682 2686
2683 /* If spec requires it, pad on right with spaces. */ 2687 /* If spec requires it, pad on right with spaces. */
2684 padding = minlen - width; 2688 padding = minlen - width;
@@ -2707,6 +2711,21 @@ Use %% to put a single % into the output.")
2707 *p++ = ' '; 2711 *p++ = ' ';
2708 nchars++; 2712 nchars++;
2709 } 2713 }
2714
2715 /* If this argument has text properties, record where
2716 in the result string it appears. */
2717 if (XSTRING (args[n])->intervals)
2718 {
2719 if (!info)
2720 {
2721 int nbytes = nargs * sizeof *info;
2722 info = (struct info *) alloca (nbytes);
2723 bzero (info, nbytes);
2724 }
2725
2726 info[n].start = start;
2727 info[n].end = nchars;
2728 }
2710 } 2729 }
2711 else if (INTEGERP (args[n]) || FLOATP (args[n])) 2730 else if (INTEGERP (args[n]) || FLOATP (args[n]))
2712 { 2731 {
@@ -2764,6 +2783,43 @@ Use %% to put a single % into the output.")
2764 if (total >= 1000) 2783 if (total >= 1000)
2765 xfree (buf); 2784 xfree (buf);
2766 2785
2786 /* If the format string has text properties, or any of the string
2787 arguments has text properties, set up text properties of the
2788 result string. */
2789
2790 if (XSTRING (args[0])->intervals || info)
2791 {
2792 Lisp_Object len, new_len, props;
2793 struct gcpro gcpro1;
2794
2795 /* Add text properties from the format string. */
2796 len = make_number (XSTRING (args[0])->size);
2797 props = text_property_list (args[0], make_number (0), len, Qnil);
2798 GCPRO1 (props);
2799
2800 if (CONSP (props))
2801 {
2802 new_len = make_number (XSTRING (val)->size);
2803 extend_property_ranges (props, len, new_len);
2804 add_text_properties_from_list (val, props, make_number (0));
2805 }
2806
2807 /* Add text properties from arguments. */
2808 if (info)
2809 for (n = 1; n < nargs; ++n)
2810 if (info[n].end)
2811 {
2812 len = make_number (XSTRING (args[n])->size);
2813 new_len = make_number (info[n].end - info[n].start);
2814 props = text_property_list (args[n], make_number (0), len, Qnil);
2815 extend_property_ranges (props, len, new_len);
2816 add_text_properties_from_list (val, props,
2817 make_number (info[n].start));
2818 }
2819
2820 UNGCPRO;
2821 }
2822
2767 return val; 2823 return val;
2768} 2824}
2769 2825