aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMiles Bader2001-10-05 12:25:26 +0000
committerMiles Bader2001-10-05 12:25:26 +0000
commita346ec72156de1ba197ee2256f721255ee2c6623 (patch)
treeabd94b9662c60f24e7ef9524cb19e3cca87d3eed /src
parenta0fb44927fe9938c61ce86dde5ca036868130076 (diff)
downloademacs-a346ec72156de1ba197ee2256f721255ee2c6623.tar.gz
emacs-a346ec72156de1ba197ee2256f721255ee2c6623.zip
(Fminibuffer_prompt_end, Fminibuffer_contents)
(Fminibuffer_contents_no_properties, Fdelete_minibuffer_contents): New functions (were in simple.el). (Fminibuffer_complete_and_exit, Fminibuffer_complete_word) (read_minibuf, do_completion, Fminibuffer_completion_help): Use them. (syms_of_minibuf): Initialize them.
Diffstat (limited to 'src')
-rw-r--r--src/minibuf.c90
1 files changed, 72 insertions, 18 deletions
diff --git a/src/minibuf.c b/src/minibuf.c
index da681c39cf2..8ffb6c70d85 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -324,6 +324,55 @@ read_minibuf_noninteractive (map, initial, prompt, backup_n, expflag,
324} 324}
325 325
326 326
327DEFUN ("minibuffer-prompt-end", Fminibuffer_prompt_end,
328 Sminibuffer_prompt_end, 0, 0, 0,
329 "Return the buffer position of the end of the minibuffer prompt.\n\
330Return (point-min) if current buffer is not a mini-buffer.")
331 ()
332{
333 /* This function is written to be most efficient when there's a prompt. */
334 Lisp_Object beg = make_number (BEGV);
335 Lisp_Object end = Ffield_end (beg, Qnil);
336
337 if (XINT (end) == ZV && NILP (Fget_char_property (beg, Qfield, Qnil)))
338 return make_number (beg);
339 else
340 return end;
341}
342
343DEFUN ("minibuffer-contents", Fminibuffer_contents,
344 Sminibuffer_contents, 0, 0, 0,
345 "Return the user input in a minbuffer as a string.\n\
346The current buffer must be a minibuffer.")
347 ()
348{
349 int prompt_end = XINT (Fminibuffer_prompt_end ());
350 return make_buffer_string (prompt_end, ZV, 1);
351}
352
353DEFUN ("minibuffer-contents-no-properties", Fminibuffer_contents_no_properties,
354 Sminibuffer_contents_no_properties, 0, 0, 0,
355 "Return the user input in a minbuffer as a string, without text-properties.\n\
356The current buffer must be a minibuffer.")
357 ()
358{
359 int prompt_end = XINT (Fminibuffer_prompt_end ());
360 return make_buffer_string (prompt_end, ZV, 0);
361}
362
363DEFUN ("delete-minibuffer-contents", Fdelete_minibuffer_contents,
364 Sdelete_minibuffer_contents, 0, 0, 0,
365 "Delete all user input in a minibuffer.\n\
366The current buffer must be a minibuffer.")
367 ()
368{
369 int prompt_end = XINT (Fminibuffer_prompt_end ());
370 if (prompt_end < ZV)
371 del_range (prompt_end, ZV);
372 return Qnil;
373}
374
375
327/* Read from the minibuffer using keymap MAP, initial contents INITIAL 376/* Read from the minibuffer using keymap MAP, initial contents INITIAL
328 (a string), putting point minus BACKUP_N bytes from the end of INITIAL, 377 (a string), putting point minus BACKUP_N bytes from the end of INITIAL,
329 prompting with PROMPT (a string), using history list HISTVAR 378 prompting with PROMPT (a string), using history list HISTVAR
@@ -585,9 +634,9 @@ read_minibuf (map, initial, prompt, backup_n, expflag,
585 /* Make minibuffer contents into a string. */ 634 /* Make minibuffer contents into a string. */
586 Fset_buffer (minibuffer); 635 Fset_buffer (minibuffer);
587 if (allow_props) 636 if (allow_props)
588 val = Ffield_string (make_number (ZV)); 637 val = Fminibuffer_contents ();
589 else 638 else
590 val = Ffield_string_no_properties (make_number (ZV)); 639 val = Fminibuffer_contents_no_properties ();
591 640
592 /* VAL is the string of minibuffer text. */ 641 /* VAL is the string of minibuffer text. */
593 642
@@ -1596,7 +1645,7 @@ do_completion ()
1596 Lisp_Object last; 1645 Lisp_Object last;
1597 struct gcpro gcpro1, gcpro2; 1646 struct gcpro gcpro1, gcpro2;
1598 1647
1599 completion = Ftry_completion (Ffield_string (make_number (ZV)), 1648 completion = Ftry_completion (Fminibuffer_contents (),
1600 Vminibuffer_completion_table, 1649 Vminibuffer_completion_table,
1601 Vminibuffer_completion_predicate); 1650 Vminibuffer_completion_predicate);
1602 last = last_exact_completion; 1651 last = last_exact_completion;
@@ -1618,7 +1667,7 @@ do_completion ()
1618 return 1; 1667 return 1;
1619 } 1668 }
1620 1669
1621 string = Ffield_string (make_number (ZV)); 1670 string = Fminibuffer_contents ();
1622 1671
1623 /* COMPLETEDP should be true if some completion was done, which 1672 /* COMPLETEDP should be true if some completion was done, which
1624 doesn't include simply changing the case of the entered string. 1673 doesn't include simply changing the case of the entered string.
@@ -1631,7 +1680,7 @@ do_completion ()
1631 if (!EQ (tem, Qt)) 1680 if (!EQ (tem, Qt))
1632 /* Rewrite the user's input. */ 1681 /* Rewrite the user's input. */
1633 { 1682 {
1634 Fdelete_field (make_number (ZV)); /* Some completion happened */ 1683 Fdelete_minibuffer_contents (); /* Some completion happened */
1635 Finsert (1, &completion); 1684 Finsert (1, &completion);
1636 1685
1637 if (! completedp) 1686 if (! completedp)
@@ -1647,7 +1696,7 @@ do_completion ()
1647 } 1696 }
1648 1697
1649 /* It did find a match. Do we match some possibility exactly now? */ 1698 /* It did find a match. Do we match some possibility exactly now? */
1650 tem = test_completion (Ffield_string (make_number (ZV))); 1699 tem = test_completion (Fminibuffer_contents ());
1651 if (NILP (tem)) 1700 if (NILP (tem))
1652 { 1701 {
1653 /* not an exact match */ 1702 /* not an exact match */
@@ -1671,7 +1720,7 @@ do_completion ()
1671 last_exact_completion = completion; 1720 last_exact_completion = completion;
1672 if (!NILP (last)) 1721 if (!NILP (last))
1673 { 1722 {
1674 tem = Ffield_string (make_number (ZV)); 1723 tem = Fminibuffer_contents ();
1675 if (!NILP (Fequal (tem, last))) 1724 if (!NILP (Fequal (tem, last)))
1676 Fminibuffer_completion_help (); 1725 Fminibuffer_completion_help ();
1677 } 1726 }
@@ -1796,10 +1845,10 @@ a repetition of this command will exit.")
1796 Lisp_Object val; 1845 Lisp_Object val;
1797 1846
1798 /* Allow user to specify null string */ 1847 /* Allow user to specify null string */
1799 if (XINT (Ffield_beginning (make_number (ZV), Qnil)) == ZV) 1848 if (XINT (Fminibuffer_prompt_end ()) == ZV)
1800 goto exit; 1849 goto exit;
1801 1850
1802 if (!NILP (test_completion (Ffield_string (make_number (ZV))))) 1851 if (!NILP (test_completion (Fminibuffer_contents ())))
1803 goto exit; 1852 goto exit;
1804 1853
1805 /* Call do_completion, but ignore errors. */ 1854 /* Call do_completion, but ignore errors. */
@@ -1847,7 +1896,7 @@ Return nil if there is no valid completion, else t.")
1847 /* We keep calling Fbuffer_string rather than arrange for GC to 1896 /* We keep calling Fbuffer_string rather than arrange for GC to
1848 hold onto a pointer to one of the strings thus made. */ 1897 hold onto a pointer to one of the strings thus made. */
1849 1898
1850 completion = Ftry_completion (Ffield_string (make_number (ZV)), 1899 completion = Ftry_completion (Fminibuffer_contents (),
1851 Vminibuffer_completion_table, 1900 Vminibuffer_completion_table,
1852 Vminibuffer_completion_predicate); 1901 Vminibuffer_completion_predicate);
1853 if (NILP (completion)) 1902 if (NILP (completion))
@@ -1860,7 +1909,7 @@ Return nil if there is no valid completion, else t.")
1860 return Qnil; 1909 return Qnil;
1861 1910
1862#if 0 /* How the below code used to look, for reference. */ 1911#if 0 /* How the below code used to look, for reference. */
1863 tem = Ffield_string (make_number (ZV)); 1912 tem = Fminibuffer_contents ();
1864 b = XSTRING (tem)->data; 1913 b = XSTRING (tem)->data;
1865 i = ZV - 1 - XSTRING (completion)->size; 1914 i = ZV - 1 - XSTRING (completion)->size;
1866 p = XSTRING (completion)->data; 1915 p = XSTRING (completion)->data;
@@ -1879,7 +1928,7 @@ Return nil if there is no valid completion, else t.")
1879 int buffer_nchars, completion_nchars; 1928 int buffer_nchars, completion_nchars;
1880 1929
1881 CHECK_STRING (completion, 0); 1930 CHECK_STRING (completion, 0);
1882 tem = Ffield_string (make_number (ZV)); 1931 tem = Fminibuffer_contents ();
1883 GCPRO2 (completion, tem); 1932 GCPRO2 (completion, tem);
1884 /* If reading a file name, 1933 /* If reading a file name,
1885 expand any $ENVVAR refs in the buffer and in TEM. */ 1934 expand any $ENVVAR refs in the buffer and in TEM. */
@@ -1890,7 +1939,7 @@ Return nil if there is no valid completion, else t.")
1890 if (! EQ (substituted, tem)) 1939 if (! EQ (substituted, tem))
1891 { 1940 {
1892 tem = substituted; 1941 tem = substituted;
1893 Fdelete_field (make_number (ZV)); 1942 Fdelete_minibuffer_contents ();
1894 insert_from_string (tem, 0, 0, XSTRING (tem)->size, 1943 insert_from_string (tem, 0, 0, XSTRING (tem)->size,
1895 STRING_BYTES (XSTRING (tem)), 0); 1944 STRING_BYTES (XSTRING (tem)), 0);
1896 } 1945 }
@@ -1932,7 +1981,7 @@ Return nil if there is no valid completion, else t.")
1932 } 1981 }
1933#endif /* Rewritten code */ 1982#endif /* Rewritten code */
1934 1983
1935 prompt_end_charpos = XINT (Ffield_beginning (make_number (ZV), Qnil)); 1984 prompt_end_charpos = XINT (Fminibuffer_prompt_end ());
1936 1985
1937 { 1986 {
1938 int prompt_end_bytepos; 1987 int prompt_end_bytepos;
@@ -1946,7 +1995,7 @@ Return nil if there is no valid completion, else t.")
1946 if (i == XSTRING (completion)->size) 1995 if (i == XSTRING (completion)->size)
1947 { 1996 {
1948 GCPRO1 (completion); 1997 GCPRO1 (completion);
1949 tem = Ftry_completion (concat2 (Ffield_string (make_number (ZV)), build_string (" ")), 1998 tem = Ftry_completion (concat2 (Fminibuffer_contents (), build_string (" ")),
1950 Vminibuffer_completion_table, 1999 Vminibuffer_completion_table,
1951 Vminibuffer_completion_predicate); 2000 Vminibuffer_completion_predicate);
1952 UNGCPRO; 2001 UNGCPRO;
@@ -1957,7 +2006,7 @@ Return nil if there is no valid completion, else t.")
1957 { 2006 {
1958 GCPRO1 (completion); 2007 GCPRO1 (completion);
1959 tem = 2008 tem =
1960 Ftry_completion (concat2 (Ffield_string (make_number (ZV)), build_string ("-")), 2009 Ftry_completion (concat2 (Fminibuffer_contents (), build_string ("-")),
1961 Vminibuffer_completion_table, 2010 Vminibuffer_completion_table,
1962 Vminibuffer_completion_predicate); 2011 Vminibuffer_completion_predicate);
1963 UNGCPRO; 2012 UNGCPRO;
@@ -1998,7 +2047,7 @@ Return nil if there is no valid completion, else t.")
1998 2047
1999 /* Otherwise insert in minibuffer the chars we got */ 2048 /* Otherwise insert in minibuffer the chars we got */
2000 2049
2001 Fdelete_field (make_number (ZV)); 2050 Fdelete_minibuffer_contents ();
2002 insert_from_string (completion, 0, 0, i, i_byte, 1); 2051 insert_from_string (completion, 0, 0, i, i_byte, 1);
2003 return Qt; 2052 return Qt;
2004} 2053}
@@ -2194,7 +2243,7 @@ DEFUN ("minibuffer-completion-help", Fminibuffer_completion_help, Sminibuffer_co
2194 Lisp_Object completions; 2243 Lisp_Object completions;
2195 2244
2196 message ("Making completion list..."); 2245 message ("Making completion list...");
2197 completions = Fall_completions (Ffield_string (make_number (ZV)), 2246 completions = Fall_completions (Fminibuffer_contents (),
2198 Vminibuffer_completion_table, 2247 Vminibuffer_completion_table,
2199 Vminibuffer_completion_predicate, 2248 Vminibuffer_completion_predicate,
2200 Qt); 2249 Qt);
@@ -2471,6 +2520,11 @@ properties.");
2471 defsubr (&Sminibuffer_depth); 2520 defsubr (&Sminibuffer_depth);
2472 defsubr (&Sminibuffer_prompt); 2521 defsubr (&Sminibuffer_prompt);
2473 2522
2523 defsubr (&Sminibuffer_prompt_end);
2524 defsubr (&Sminibuffer_contents);
2525 defsubr (&Sminibuffer_contents_no_properties);
2526 defsubr (&Sdelete_minibuffer_contents);
2527
2474 defsubr (&Stry_completion); 2528 defsubr (&Stry_completion);
2475 defsubr (&Sall_completions); 2529 defsubr (&Sall_completions);
2476 defsubr (&Scompleting_read); 2530 defsubr (&Scompleting_read);