Mercurial > emacs
comparison src/minibuf.c @ 25354:2049a0c919a1
Remove conditional compilation on
NO_PROMPT_IN_BUFFER.
(Fminibuffer_prompt_end): New.
(syms_of_minibuf): Defsubr it. Remove
minibuffer-prompt-in-buffer.
(Fminibuffer_prompt_width): Return 0 if not in mini-buffer.
Extend documentation.
(read_minibuf): Use clear_message instead of
setting echo_area_glyphs.
(Fminibuffer_completion_help): Ditto.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Sat, 21 Aug 1999 19:30:16 +0000 |
parents | 1c522baf1a3c |
children | e0cfeb5dc848 |
comparison
equal
deleted
inserted
replaced
25353:fa9f34ec4151 | 25354:2049a0c919a1 |
---|---|
127 Lisp_Object Qminibuffer_default; | 127 Lisp_Object Qminibuffer_default; |
128 | 128 |
129 Lisp_Object Qcurrent_input_method, Qactivate_input_method; | 129 Lisp_Object Qcurrent_input_method, Qactivate_input_method; |
130 | 130 |
131 extern Lisp_Object Qmouse_face; | 131 extern Lisp_Object Qmouse_face; |
132 | |
133 /* If the following variable is bound, mini-buffer prompts are | |
134 inserted into mini-buffers instead of being displayed via | |
135 display_string. Tested in simple.el. No other use. */ | |
136 | |
137 #if !NO_PROMPT_IN_BUFFER | |
138 Lisp_Object Vminibuffer_prompt_in_buffer; | |
139 #endif | |
140 | 132 |
141 | 133 |
142 /* Put minibuf on currently selected frame's minibuffer. | 134 /* Put minibuf on currently selected frame's minibuffer. |
143 We do this whenever the user starts a new minibuffer | 135 We do this whenever the user starts a new minibuffer |
144 or when a minibuffer exits. */ | 136 or when a minibuffer exits. */ |
246 Lisp_Object val; | 238 Lisp_Object val; |
247 int count = specpdl_ptr - specpdl; | 239 int count = specpdl_ptr - specpdl; |
248 Lisp_Object mini_frame, ambient_dir, minibuffer, input_method; | 240 Lisp_Object mini_frame, ambient_dir, minibuffer, input_method; |
249 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; | 241 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; |
250 Lisp_Object enable_multibyte; | 242 Lisp_Object enable_multibyte; |
251 #if !NO_PROMPT_IN_BUFFER | |
252 extern Lisp_Object Qinvisible, Qintangible, Qread_only, Qfront_sticky; | 243 extern Lisp_Object Qinvisible, Qintangible, Qread_only, Qfront_sticky; |
253 #endif | |
254 | 244 |
255 specbind (Qminibuffer_default, defalt); | 245 specbind (Qminibuffer_default, defalt); |
256 | 246 |
257 single_kboard_state (); | 247 single_kboard_state (); |
258 | 248 |
318 Fcons (Vhelp_form, | 308 Fcons (Vhelp_form, |
319 Fcons (Vcurrent_prefix_arg, | 309 Fcons (Vcurrent_prefix_arg, |
320 Fcons (Vminibuffer_history_position, | 310 Fcons (Vminibuffer_history_position, |
321 Fcons (Vminibuffer_history_variable, | 311 Fcons (Vminibuffer_history_variable, |
322 minibuf_save_list)))))); | 312 minibuf_save_list)))))); |
323 #if !NO_PROMPT_IN_BUFFER | |
324 minibuf_save_list | 313 minibuf_save_list |
325 = Fcons (current_buffer->minibuffer_prompt_length, | 314 = Fcons (current_buffer->minibuffer_prompt_length, |
326 minibuf_save_list); | 315 minibuf_save_list); |
327 #endif | |
328 | 316 |
329 record_unwind_protect (read_minibuf_unwind, Qnil); | 317 record_unwind_protect (read_minibuf_unwind, Qnil); |
330 minibuf_level++; | 318 minibuf_level++; |
331 | 319 |
332 /* Now that we can restore all those variables, start changing them. */ | 320 /* Now that we can restore all those variables, start changing them. */ |
387 Fselect_window (minibuf_window); | 375 Fselect_window (minibuf_window); |
388 XSETFASTINT (XWINDOW (minibuf_window)->hscroll, 0); | 376 XSETFASTINT (XWINDOW (minibuf_window)->hscroll, 0); |
389 | 377 |
390 Fmake_local_variable (Qprint_escape_newlines); | 378 Fmake_local_variable (Qprint_escape_newlines); |
391 print_escape_newlines = 1; | 379 print_escape_newlines = 1; |
392 #if !NO_PROMPT_IN_BUFFER | |
393 XSETFASTINT (current_buffer->minibuffer_prompt_length, 0); | 380 XSETFASTINT (current_buffer->minibuffer_prompt_length, 0); |
394 #endif | |
395 | 381 |
396 /* Erase the buffer. */ | 382 /* Erase the buffer. */ |
397 { | 383 { |
398 int count1 = specpdl_ptr - specpdl; | 384 int count1 = specpdl_ptr - specpdl; |
399 specbind (Qinhibit_read_only, Qt); | 385 specbind (Qinhibit_read_only, Qt); |
403 | 389 |
404 if (!NILP (current_buffer->enable_multibyte_characters) | 390 if (!NILP (current_buffer->enable_multibyte_characters) |
405 && ! STRING_MULTIBYTE (minibuf_prompt)) | 391 && ! STRING_MULTIBYTE (minibuf_prompt)) |
406 minibuf_prompt = Fstring_make_multibyte (minibuf_prompt); | 392 minibuf_prompt = Fstring_make_multibyte (minibuf_prompt); |
407 | 393 |
408 #if !NO_PROMPT_IN_BUFFER | |
409 /* Insert the prompt, record where it ends. */ | 394 /* Insert the prompt, record where it ends. */ |
410 Finsert (1, &minibuf_prompt); | 395 Finsert (1, &minibuf_prompt); |
411 XSETFASTINT (current_buffer->minibuffer_prompt_length, PT); | 396 XSETFASTINT (current_buffer->minibuffer_prompt_length, PT); |
412 if (PT > BEG) | 397 if (PT > BEG) |
413 { | 398 { |
416 Fput_text_property (make_number (BEG), make_number (PT - 1), | 401 Fput_text_property (make_number (BEG), make_number (PT - 1), |
417 Qread_only, Qt, Qnil); | 402 Qread_only, Qt, Qnil); |
418 Fput_text_property (make_number (PT - 1), make_number (Z), | 403 Fput_text_property (make_number (PT - 1), make_number (Z), |
419 Qrear_nonsticky, Qt, Qnil); | 404 Qrear_nonsticky, Qt, Qnil); |
420 } | 405 } |
421 #endif | |
422 | 406 |
423 /* If appropriate, copy enable-multibyte-characters into the minibuffer. */ | 407 /* If appropriate, copy enable-multibyte-characters into the minibuffer. */ |
424 if (inherit_input_method) | 408 if (inherit_input_method) |
425 current_buffer->enable_multibyte_characters = enable_multibyte; | 409 current_buffer->enable_multibyte_characters = enable_multibyte; |
426 | 410 |
430 Finsert (1, &initial); | 414 Finsert (1, &initial); |
431 if (INTEGERP (backup_n)) | 415 if (INTEGERP (backup_n)) |
432 Fforward_char (backup_n); | 416 Fforward_char (backup_n); |
433 } | 417 } |
434 | 418 |
435 echo_area_glyphs = 0; | 419 clear_message (1, 1); |
436 /* This is in case the minibuffer-setup-hook calls Fsit_for. */ | |
437 previous_echo_glyphs = 0; | |
438 echo_area_message = previous_echo_area_message = Qnil, | |
439 | |
440 current_buffer->keymap = map; | 420 current_buffer->keymap = map; |
441 | 421 |
442 /* Turn on an input method stored in INPUT_METHOD if any. */ | 422 /* Turn on an input method stored in INPUT_METHOD if any. */ |
443 if (STRINGP (input_method) && !NILP (Ffboundp (Qactivate_input_method))) | 423 if (STRINGP (input_method) && !NILP (Ffboundp (Qactivate_input_method))) |
444 call1 (Qactivate_input_method, input_method); | 424 call1 (Qactivate_input_method, input_method); |
616 /* To keep things predictable, in case it matters, let's be in the | 596 /* To keep things predictable, in case it matters, let's be in the |
617 minibuffer when we reset the relevant variables. */ | 597 minibuffer when we reset the relevant variables. */ |
618 Fset_buffer (XWINDOW (window)->buffer); | 598 Fset_buffer (XWINDOW (window)->buffer); |
619 | 599 |
620 /* Restore prompt, etc, from outer minibuffer level. */ | 600 /* Restore prompt, etc, from outer minibuffer level. */ |
621 #if !NO_PROMPT_IN_BUFFER | |
622 current_buffer->minibuffer_prompt_length = Fcar (minibuf_save_list); | 601 current_buffer->minibuffer_prompt_length = Fcar (minibuf_save_list); |
623 minibuf_save_list = Fcdr (minibuf_save_list); | 602 minibuf_save_list = Fcdr (minibuf_save_list); |
624 #endif | |
625 | 603 |
626 minibuf_prompt = Fcar (minibuf_save_list); | 604 minibuf_prompt = Fcar (minibuf_save_list); |
627 minibuf_save_list = Fcdr (minibuf_save_list); | 605 minibuf_save_list = Fcdr (minibuf_save_list); |
628 minibuf_prompt_width = XFASTINT (Fcar (minibuf_save_list)); | 606 minibuf_prompt_width = XFASTINT (Fcar (minibuf_save_list)); |
629 minibuf_save_list = Fcdr (minibuf_save_list); | 607 minibuf_save_list = Fcdr (minibuf_save_list); |
1665 { | 1643 { |
1666 register int i; | 1644 register int i; |
1667 Lisp_Object val; | 1645 Lisp_Object val; |
1668 | 1646 |
1669 /* Allow user to specify null string */ | 1647 /* Allow user to specify null string */ |
1670 #if !NO_PROMPT_IN_BUFFER | |
1671 if (XFASTINT (current_buffer->minibuffer_prompt_length) == ZV) | 1648 if (XFASTINT (current_buffer->minibuffer_prompt_length) == ZV) |
1672 #else | |
1673 if (BEGV == ZV) | |
1674 #endif | |
1675 goto exit; | 1649 goto exit; |
1676 | 1650 |
1677 if (!NILP (test_completion (Fbuffer_string ()))) | 1651 if (!NILP (test_completion (Fbuffer_string ()))) |
1678 goto exit; | 1652 goto exit; |
1679 | 1653 |
1804 } | 1778 } |
1805 UNGCPRO; | 1779 UNGCPRO; |
1806 } | 1780 } |
1807 #endif /* Rewritten code */ | 1781 #endif /* Rewritten code */ |
1808 | 1782 |
1809 #if !NO_PROMPT_IN_BUFFER | |
1810 { | 1783 { |
1811 int prompt_end_charpos, prompt_end_bytepos; | 1784 int prompt_end_charpos, prompt_end_bytepos; |
1812 prompt_end_charpos = XFASTINT (current_buffer->minibuffer_prompt_length); | 1785 prompt_end_charpos = XFASTINT (current_buffer->minibuffer_prompt_length); |
1813 prompt_end_bytepos = CHAR_TO_BYTE (prompt_end_charpos); | 1786 prompt_end_bytepos = CHAR_TO_BYTE (prompt_end_charpos); |
1814 i = ZV - prompt_end_charpos; | 1787 i = ZV - prompt_end_charpos; |
1815 i_byte = ZV_BYTE - prompt_end_bytepos; | 1788 i_byte = ZV_BYTE - prompt_end_bytepos; |
1816 } | 1789 } |
1817 #else | |
1818 i = ZV - BEGV; | |
1819 i_byte = ZV_BYTE - BEGV_BYTE; | |
1820 #endif | |
1821 | 1790 |
1822 /* If completion finds next char not unique, | 1791 /* If completion finds next char not unique, |
1823 consider adding a space or a hyphen. */ | 1792 consider adding a space or a hyphen. */ |
1824 if (i == XSTRING (completion)->size) | 1793 if (i == XSTRING (completion)->size) |
1825 { | 1794 { |
1865 } | 1834 } |
1866 } | 1835 } |
1867 | 1836 |
1868 /* If got no characters, print help for user. */ | 1837 /* If got no characters, print help for user. */ |
1869 | 1838 |
1870 #if !NO_PROMPT_IN_BUFFER | |
1871 if (i == ZV - XFASTINT (current_buffer->minibuffer_prompt_length)) | 1839 if (i == ZV - XFASTINT (current_buffer->minibuffer_prompt_length)) |
1872 #else | |
1873 if (i == ZV - BEGV) | |
1874 #endif | |
1875 { | 1840 { |
1876 if (auto_help) | 1841 if (auto_help) |
1877 Fminibuffer_completion_help (); | 1842 Fminibuffer_completion_help (); |
1878 return Qnil; | 1843 return Qnil; |
1879 } | 1844 } |
2076 message ("Making completion list..."); | 2041 message ("Making completion list..."); |
2077 completions = Fall_completions (Fbuffer_string (), | 2042 completions = Fall_completions (Fbuffer_string (), |
2078 Vminibuffer_completion_table, | 2043 Vminibuffer_completion_table, |
2079 Vminibuffer_completion_predicate, | 2044 Vminibuffer_completion_predicate, |
2080 Qt); | 2045 Qt); |
2081 echo_area_glyphs = 0; | 2046 clear_message (1, 0); |
2082 echo_area_message = Qnil; | |
2083 | 2047 |
2084 if (NILP (completions)) | 2048 if (NILP (completions)) |
2085 { | 2049 { |
2086 bitch_at_user (); | 2050 bitch_at_user (); |
2087 temp_echo_area_glyphs (" [No completions]"); | 2051 temp_echo_area_glyphs (" [No completions]"); |
2127 return Fcopy_sequence (minibuf_prompt); | 2091 return Fcopy_sequence (minibuf_prompt); |
2128 } | 2092 } |
2129 | 2093 |
2130 DEFUN ("minibuffer-prompt-width", Fminibuffer_prompt_width, | 2094 DEFUN ("minibuffer-prompt-width", Fminibuffer_prompt_width, |
2131 Sminibuffer_prompt_width, 0, 0, 0, | 2095 Sminibuffer_prompt_width, 0, 0, 0, |
2132 "Return the display width of the minibuffer prompt.") | 2096 "Return the display width of the minibuffer prompt.\n\ |
2097 Return 0 if current buffer is not a mini-buffer.") | |
2133 () | 2098 () |
2134 { | 2099 { |
2135 Lisp_Object width; | 2100 Lisp_Object width; |
2136 #if !NO_PROMPT_IN_BUFFER | 2101 if (NILP (current_buffer->minibuffer_prompt_length)) |
2137 XSETFASTINT (width, current_buffer->minibuffer_prompt_length); | 2102 width = make_number (0); |
2138 #else | 2103 else |
2139 XSETFASTINT (width, minibuf_prompt_width); | 2104 width = make_number (current_buffer->minibuffer_prompt_length); |
2140 #endif | |
2141 return width; | 2105 return width; |
2142 } | 2106 } |
2107 | |
2108 | |
2109 DEFUN ("minibuffer-prompt-end", Fminibuffer_prompt_end, | |
2110 Sminibuffer_prompt_end, 0, 0, 0, | |
2111 "Return the end buffer position of the mini-buffer prompt.\n\ | |
2112 Value is 0 if current buffer is not a mini-buffer.") | |
2113 () | |
2114 { | |
2115 return (NILP (current_buffer->minibuffer_prompt_length) | |
2116 ? make_number (0) | |
2117 : make_number (current_buffer->minibuffer_prompt_length)); | |
2118 } | |
2119 | |
2120 | |
2143 | 2121 |
2144 /* Temporarily display the string M at the end of the current | 2122 /* Temporarily display the string M at the end of the current |
2145 minibuffer contents. This is used to display things like | 2123 minibuffer contents. This is used to display things like |
2146 "[No Match]" when the user requests a completion for a prefix | 2124 "[No Match]" when the user requests a completion for a prefix |
2147 that has no possible completions, and other quick, unobtrusive | 2125 that has no possible completions, and other quick, unobtrusive |
2250 staticpro (&Qcurrent_input_method); | 2228 staticpro (&Qcurrent_input_method); |
2251 | 2229 |
2252 Qactivate_input_method = intern ("activate-input-method"); | 2230 Qactivate_input_method = intern ("activate-input-method"); |
2253 staticpro (&Qactivate_input_method); | 2231 staticpro (&Qactivate_input_method); |
2254 | 2232 |
2255 #if !NO_PROMPT_IN_BUFFER | |
2256 /* This variable should be removed once it has been decided whether or | |
2257 not to use prompts in buffers. */ | |
2258 DEFVAR_LISP ("minibuffer-prompt-in-buffer", &Vminibuffer_prompt_in_buffer, | |
2259 "The existance of this variable indicates that mini-buffer prompts are\n\ | |
2260 inserted into the mini-buffer."); | |
2261 Vminibuffer_prompt_in_buffer = Qnil; | |
2262 #endif /* !NO_PROMPT_IN_BUFFER */ | |
2263 | |
2264 DEFVAR_LISP ("read-buffer-function", &Vread_buffer_function, | 2233 DEFVAR_LISP ("read-buffer-function", &Vread_buffer_function, |
2265 "If this is non-nil, `read-buffer' does its work by calling this function."); | 2234 "If this is non-nil, `read-buffer' does its work by calling this function."); |
2266 Vread_buffer_function = Qnil; | 2235 Vread_buffer_function = Qnil; |
2267 | 2236 |
2268 DEFVAR_LISP ("minibuffer-setup-hook", &Vminibuffer_setup_hook, | 2237 DEFVAR_LISP ("minibuffer-setup-hook", &Vminibuffer_setup_hook, |
2363 defsubr (&Sread_buffer); | 2332 defsubr (&Sread_buffer); |
2364 defsubr (&Sread_no_blanks_input); | 2333 defsubr (&Sread_no_blanks_input); |
2365 defsubr (&Sminibuffer_depth); | 2334 defsubr (&Sminibuffer_depth); |
2366 defsubr (&Sminibuffer_prompt); | 2335 defsubr (&Sminibuffer_prompt); |
2367 defsubr (&Sminibuffer_prompt_width); | 2336 defsubr (&Sminibuffer_prompt_width); |
2337 defsubr (&Sminibuffer_prompt_end); | |
2368 | 2338 |
2369 defsubr (&Stry_completion); | 2339 defsubr (&Stry_completion); |
2370 defsubr (&Sall_completions); | 2340 defsubr (&Sall_completions); |
2371 defsubr (&Scompleting_read); | 2341 defsubr (&Scompleting_read); |
2372 defsubr (&Sminibuffer_complete); | 2342 defsubr (&Sminibuffer_complete); |