aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/minibuf.c78
1 files changed, 26 insertions, 52 deletions
diff --git a/src/minibuf.c b/src/minibuf.c
index 033c598e0a1..2d9ca1b02bf 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -1,5 +1,5 @@
1/* Minibuffer input and completion. 1/* Minibuffer input and completion.
2 Copyright (C) 1985, 1986, 1993, 1994, 1995, 1996, 1997, 1998 2 Copyright (C) 1985, 1986, 1993, 1994, 1995, 1996, 1997, 1998, 1999
3 Free Software Foundation, Inc. 3 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
@@ -131,6 +131,7 @@ Lisp_Object Qcurrent_input_method, Qactivate_input_method;
131 131
132extern Lisp_Object Qmouse_face; 132extern Lisp_Object Qmouse_face;
133 133
134extern Lisp_Object Qfield;
134 135
135/* Put minibuf on currently selected frame's minibuffer. 136/* Put minibuf on currently selected frame's minibuffer.
136 We do this whenever the user starts a new minibuffer 137 We do this whenever the user starts a new minibuffer
@@ -318,9 +319,6 @@ read_minibuf (map, initial, prompt, backup_n, expflag,
318 Fcons (Vminibuffer_history_position, 319 Fcons (Vminibuffer_history_position,
319 Fcons (Vminibuffer_history_variable, 320 Fcons (Vminibuffer_history_variable,
320 minibuf_save_list)))))); 321 minibuf_save_list))))));
321 minibuf_save_list
322 = Fcons (current_buffer->prompt_end_charpos,
323 minibuf_save_list);
324 322
325 record_unwind_protect (read_minibuf_unwind, Qnil); 323 record_unwind_protect (read_minibuf_unwind, Qnil);
326 minibuf_level++; 324 minibuf_level++;
@@ -385,7 +383,6 @@ read_minibuf (map, initial, prompt, backup_n, expflag,
385 383
386 Fmake_local_variable (Qprint_escape_newlines); 384 Fmake_local_variable (Qprint_escape_newlines);
387 print_escape_newlines = 1; 385 print_escape_newlines = 1;
388 XSETFASTINT (current_buffer->prompt_end_charpos, 0);
389 386
390 /* Erase the buffer. */ 387 /* Erase the buffer. */
391 { 388 {
@@ -401,7 +398,6 @@ read_minibuf (map, initial, prompt, backup_n, expflag,
401 398
402 /* Insert the prompt, record where it ends. */ 399 /* Insert the prompt, record where it ends. */
403 Finsert (1, &minibuf_prompt); 400 Finsert (1, &minibuf_prompt);
404 XSETFASTINT (current_buffer->prompt_end_charpos, PT);
405 if (PT > BEG) 401 if (PT > BEG)
406 { 402 {
407 Fput_text_property (make_number (BEG), make_number (PT), 403 Fput_text_property (make_number (BEG), make_number (PT),
@@ -409,6 +405,8 @@ read_minibuf (map, initial, prompt, backup_n, expflag,
409 Fput_text_property (make_number (BEG), make_number (PT), 405 Fput_text_property (make_number (BEG), make_number (PT),
410 Qrear_nonsticky, Qt, Qnil); 406 Qrear_nonsticky, Qt, Qnil);
411 Fput_text_property (make_number (BEG), make_number (PT), 407 Fput_text_property (make_number (BEG), make_number (PT),
408 Qfield, Qt, Qnil);
409 Fput_text_property (make_number (BEG), make_number (PT),
412 Qread_only, Qt, Qnil); 410 Qread_only, Qt, Qnil);
413 } 411 }
414 412
@@ -457,8 +455,7 @@ read_minibuf (map, initial, prompt, backup_n, expflag,
457 455
458 /* Make minibuffer contents into a string. */ 456 /* Make minibuffer contents into a string. */
459 Fset_buffer (minibuffer); 457 Fset_buffer (minibuffer);
460 val = make_buffer_string (current_buffer->prompt_end_charpos, 458 val = Ffield_string (make_number (ZV), allow_props ? Qt : Qnil);
461 Z, allow_props);
462 459
463 /* VAL is the string of minibuffer text. */ 460 /* VAL is the string of minibuffer text. */
464 461
@@ -610,9 +607,6 @@ read_minibuf_unwind (data)
610 Fset_buffer (XWINDOW (window)->buffer); 607 Fset_buffer (XWINDOW (window)->buffer);
611 608
612 /* Restore prompt, etc, from outer minibuffer level. */ 609 /* Restore prompt, etc, from outer minibuffer level. */
613 current_buffer->prompt_end_charpos = Fcar (minibuf_save_list);
614 minibuf_save_list = Fcdr (minibuf_save_list);
615
616 minibuf_prompt = Fcar (minibuf_save_list); 610 minibuf_prompt = Fcar (minibuf_save_list);
617 minibuf_save_list = Fcdr (minibuf_save_list); 611 minibuf_save_list = Fcdr (minibuf_save_list);
618 minibuf_prompt_width = XFASTINT (Fcar (minibuf_save_list)); 612 minibuf_prompt_width = XFASTINT (Fcar (minibuf_save_list));
@@ -1484,7 +1478,8 @@ do_completion ()
1484 Lisp_Object last; 1478 Lisp_Object last;
1485 struct gcpro gcpro1, gcpro2; 1479 struct gcpro gcpro1, gcpro2;
1486 1480
1487 completion = Ftry_completion (Fbuffer_string (), Vminibuffer_completion_table, 1481 completion = Ftry_completion (Ffield_string (ZV),
1482 Vminibuffer_completion_table,
1488 Vminibuffer_completion_predicate); 1483 Vminibuffer_completion_predicate);
1489 last = last_exact_completion; 1484 last = last_exact_completion;
1490 last_exact_completion = Qnil; 1485 last_exact_completion = Qnil;
@@ -1506,16 +1501,16 @@ do_completion ()
1506 } 1501 }
1507 1502
1508 /* compiler bug */ 1503 /* compiler bug */
1509 tem = Fstring_equal (completion, Fbuffer_string()); 1504 tem = Fstring_equal (completion, Ffield_string(ZV));
1510 completedp = NILP (tem); 1505 completedp = NILP (tem);
1511 if (completedp) 1506 if (completedp)
1512 { 1507 {
1513 Ferase_buffer (); /* Some completion happened */ 1508 Ferase_field (make_number (ZV)); /* Some completion happened */
1514 Finsert (1, &completion); 1509 Finsert (1, &completion);
1515 } 1510 }
1516 1511
1517 /* It did find a match. Do we match some possibility exactly now? */ 1512 /* It did find a match. Do we match some possibility exactly now? */
1518 tem = test_completion (Fbuffer_string ()); 1513 tem = test_completion (Ffield_string(ZV));
1519 if (NILP (tem)) 1514 if (NILP (tem))
1520 { 1515 {
1521 /* not an exact match */ 1516 /* not an exact match */
@@ -1539,7 +1534,7 @@ do_completion ()
1539 last_exact_completion = completion; 1534 last_exact_completion = completion;
1540 if (!NILP (last)) 1535 if (!NILP (last))
1541 { 1536 {
1542 tem = Fbuffer_string (); 1537 tem = Ffield_string (ZV);
1543 if (!NILP (Fequal (tem, last))) 1538 if (!NILP (Fequal (tem, last)))
1544 Fminibuffer_completion_help (); 1539 Fminibuffer_completion_help ();
1545 } 1540 }
@@ -1660,10 +1655,10 @@ a repetition of this command will exit.")
1660 Lisp_Object val; 1655 Lisp_Object val;
1661 1656
1662 /* Allow user to specify null string */ 1657 /* Allow user to specify null string */
1663 if (XFASTINT (current_buffer->prompt_end_charpos) == ZV) 1658 if (Ffield_beginning (ZV, Qnil) == ZV)
1664 goto exit; 1659 goto exit;
1665 1660
1666 if (!NILP (test_completion (Fbuffer_string ()))) 1661 if (!NILP (test_completion (Ffield_string (ZV))))
1667 goto exit; 1662 goto exit;
1668 1663
1669 /* Call do_completion, but ignore errors. */ 1664 /* Call do_completion, but ignore errors. */
@@ -1706,11 +1701,12 @@ Return nil if there is no valid completion, else t.")
1706 register int i, i_byte; 1701 register int i, i_byte;
1707 register unsigned char *completion_string; 1702 register unsigned char *completion_string;
1708 struct gcpro gcpro1, gcpro2; 1703 struct gcpro gcpro1, gcpro2;
1704 int prompt_end_charpos;
1709 1705
1710 /* We keep calling Fbuffer_string rather than arrange for GC to 1706 /* We keep calling Fbuffer_string rather than arrange for GC to
1711 hold onto a pointer to one of the strings thus made. */ 1707 hold onto a pointer to one of the strings thus made. */
1712 1708
1713 completion = Ftry_completion (Fbuffer_string (), 1709 completion = Ftry_completion (Ffield_string (ZV),
1714 Vminibuffer_completion_table, 1710 Vminibuffer_completion_table,
1715 Vminibuffer_completion_predicate); 1711 Vminibuffer_completion_predicate);
1716 if (NILP (completion)) 1712 if (NILP (completion))
@@ -1723,7 +1719,7 @@ Return nil if there is no valid completion, else t.")
1723 return Qnil; 1719 return Qnil;
1724 1720
1725#if 0 /* How the below code used to look, for reference. */ 1721#if 0 /* How the below code used to look, for reference. */
1726 tem = Fbuffer_string (); 1722 tem = Ffield_string (ZV);
1727 b = XSTRING (tem)->data; 1723 b = XSTRING (tem)->data;
1728 i = ZV - 1 - XSTRING (completion)->size; 1724 i = ZV - 1 - XSTRING (completion)->size;
1729 p = XSTRING (completion)->data; 1725 p = XSTRING (completion)->data;
@@ -1742,7 +1738,7 @@ Return nil if there is no valid completion, else t.")
1742 int buffer_nchars, completion_nchars; 1738 int buffer_nchars, completion_nchars;
1743 1739
1744 CHECK_STRING (completion, 0); 1740 CHECK_STRING (completion, 0);
1745 tem = Fbuffer_string (); 1741 tem = Ffield_string (ZV);
1746 GCPRO2 (completion, tem); 1742 GCPRO2 (completion, tem);
1747 /* If reading a file name, 1743 /* If reading a file name,
1748 expand any $ENVVAR refs in the buffer and in TEM. */ 1744 expand any $ENVVAR refs in the buffer and in TEM. */
@@ -1753,7 +1749,7 @@ Return nil if there is no valid completion, else t.")
1753 if (! EQ (substituted, tem)) 1749 if (! EQ (substituted, tem))
1754 { 1750 {
1755 tem = substituted; 1751 tem = substituted;
1756 Ferase_buffer (); 1752 Ferase_field (make_number (ZV));
1757 insert_from_string (tem, 0, 0, XSTRING (tem)->size, 1753 insert_from_string (tem, 0, 0, XSTRING (tem)->size,
1758 STRING_BYTES (XSTRING (tem)), 0); 1754 STRING_BYTES (XSTRING (tem)), 0);
1759 } 1755 }
@@ -1795,9 +1791,10 @@ Return nil if there is no valid completion, else t.")
1795 } 1791 }
1796#endif /* Rewritten code */ 1792#endif /* Rewritten code */
1797 1793
1794 prompt_end_charpos = Ffield_beginning (make_number (ZV), Qnil);
1795
1798 { 1796 {
1799 int prompt_end_charpos, prompt_end_bytepos; 1797 int prompt_end_bytepos;
1800 prompt_end_charpos = XFASTINT (current_buffer->prompt_end_charpos);
1801 prompt_end_bytepos = CHAR_TO_BYTE (prompt_end_charpos); 1798 prompt_end_bytepos = CHAR_TO_BYTE (prompt_end_charpos);
1802 i = ZV - prompt_end_charpos; 1799 i = ZV - prompt_end_charpos;
1803 i_byte = ZV_BYTE - prompt_end_bytepos; 1800 i_byte = ZV_BYTE - prompt_end_bytepos;
@@ -1808,7 +1805,7 @@ Return nil if there is no valid completion, else t.")
1808 if (i == XSTRING (completion)->size) 1805 if (i == XSTRING (completion)->size)
1809 { 1806 {
1810 GCPRO1 (completion); 1807 GCPRO1 (completion);
1811 tem = Ftry_completion (concat2 (Fbuffer_string (), build_string (" ")), 1808 tem = Ftry_completion (concat2 (Ffield_string (ZV), build_string (" ")),
1812 Vminibuffer_completion_table, 1809 Vminibuffer_completion_table,
1813 Vminibuffer_completion_predicate); 1810 Vminibuffer_completion_predicate);
1814 UNGCPRO; 1811 UNGCPRO;
@@ -1819,7 +1816,7 @@ Return nil if there is no valid completion, else t.")
1819 { 1816 {
1820 GCPRO1 (completion); 1817 GCPRO1 (completion);
1821 tem = 1818 tem =
1822 Ftry_completion (concat2 (Fbuffer_string (), build_string ("-")), 1819 Ftry_completion (concat2 (Ffield_string (ZV), build_string ("-")),
1823 Vminibuffer_completion_table, 1820 Vminibuffer_completion_table,
1824 Vminibuffer_completion_predicate); 1821 Vminibuffer_completion_predicate);
1825 UNGCPRO; 1822 UNGCPRO;
@@ -1851,7 +1848,7 @@ Return nil if there is no valid completion, else t.")
1851 1848
1852 /* If got no characters, print help for user. */ 1849 /* If got no characters, print help for user. */
1853 1850
1854 if (i == ZV - XFASTINT (current_buffer->prompt_end_charpos)) 1851 if (i == ZV - prompt_end_charpos)
1855 { 1852 {
1856 if (auto_help) 1853 if (auto_help)
1857 Fminibuffer_completion_help (); 1854 Fminibuffer_completion_help ();
@@ -1860,7 +1857,7 @@ Return nil if there is no valid completion, else t.")
1860 1857
1861 /* Otherwise insert in minibuffer the chars we got */ 1858 /* Otherwise insert in minibuffer the chars we got */
1862 1859
1863 Ferase_buffer (); 1860 Ferase_field (make_number (ZV));
1864 insert_from_string (completion, 0, 0, i, i_byte, 1); 1861 insert_from_string (completion, 0, 0, i, i_byte, 1);
1865 return Qt; 1862 return Qt;
1866} 1863}
@@ -2054,7 +2051,7 @@ DEFUN ("minibuffer-completion-help", Fminibuffer_completion_help, Sminibuffer_co
2054 Lisp_Object completions; 2051 Lisp_Object completions;
2055 2052
2056 message ("Making completion list..."); 2053 message ("Making completion list...");
2057 completions = Fall_completions (Fbuffer_string (), 2054 completions = Fall_completions (Ffield_string (ZV),
2058 Vminibuffer_completion_table, 2055 Vminibuffer_completion_table,
2059 Vminibuffer_completion_predicate, 2056 Vminibuffer_completion_predicate,
2060 Qt); 2057 Qt);
@@ -2106,27 +2103,6 @@ If no minibuffer is active, return nil.")
2106 return Fcopy_sequence (minibuf_prompt); 2103 return Fcopy_sequence (minibuf_prompt);
2107} 2104}
2108 2105
2109DEFUN ("minibuffer-prompt-width", Fminibuffer_prompt_width,
2110 Sminibuffer_prompt_width, 0, 0, 0,
2111 "Return the display width of the minibuffer prompt.")
2112 ()
2113{
2114 return make_number (minibuf_prompt_width);
2115}
2116
2117
2118DEFUN ("minibuffer-prompt-end", Fminibuffer_prompt_end,
2119 Sminibuffer_prompt_end, 0, 0, 0,
2120 "Return the end buffer position of the mini-buffer prompt.\n\
2121Value is 0 if current buffer is not a mini-buffer.")
2122 ()
2123{
2124 return (NILP (current_buffer->prompt_end_charpos)
2125 ? make_number (0)
2126 : make_number (current_buffer->prompt_end_charpos));
2127}
2128
2129
2130 2106
2131/* Temporarily display the string M at the end of the current 2107/* Temporarily display the string M at the end of the current
2132 minibuffer contents. This is used to display things like 2108 minibuffer contents. This is used to display things like
@@ -2342,8 +2318,6 @@ with completion; they always discard text properties.");
2342 defsubr (&Sread_no_blanks_input); 2318 defsubr (&Sread_no_blanks_input);
2343 defsubr (&Sminibuffer_depth); 2319 defsubr (&Sminibuffer_depth);
2344 defsubr (&Sminibuffer_prompt); 2320 defsubr (&Sminibuffer_prompt);
2345 defsubr (&Sminibuffer_prompt_width);
2346 defsubr (&Sminibuffer_prompt_end);
2347 2321
2348 defsubr (&Stry_completion); 2322 defsubr (&Stry_completion);
2349 defsubr (&Sall_completions); 2323 defsubr (&Sall_completions);