diff options
| author | Gerd Moellmann | 1999-07-21 21:43:52 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 1999-07-21 21:43:52 +0000 |
| commit | 279cf52c7f4b2a0d43a95ddac302e6372d494905 (patch) | |
| tree | 151b91b4ac536084004a92f9ade9676f75b35614 /src | |
| parent | 43c70fcf91e4ba765ee4092071305c1063aee3b7 (diff) | |
| download | emacs-279cf52c7f4b2a0d43a95ddac302e6372d494905.tar.gz emacs-279cf52c7f4b2a0d43a95ddac302e6372d494905.zip | |
(read_minibuf): Reset echo message strings to nil.
(Fminibuffer_completion_help): Ditto.
(Fminibuffer_complete_word): Fix computation of
i_byte when prompts are inserted into minibuffers.
(read_minibuf): Use minibuf_prompt instead of prompt.
(read_minibuf): Add front-sticky text property for prompt.
(read_minibuf_unwind): Return Lisp_Object.
(read_minibuf): Put access to minibuffer_prompt_length
in #if PROMPT_IN_BUFFER.
(minibuffer-prompt-in-buffer): Bound if
PROMPT_IN_BUFFER.
(read_minibuf): Save the value of
minibuffer_prompt_length in minibuf_save_list.
(read_minibuf_unwind): Restore minibuffer_prompt_length.
(Fminibuffer_prompt_width): Return value from
current_buffer if PROMPT_IN_BUFFER.
(read_minibuf): If PROMPT_IN_BUFFER, insert prompt into
mini-buffer and make it read-only.
(Fminibuffer_complete_and_exit): If PROMPT_IN_BUFFER, use
minibuffer_prompt_length instead of BEGV.
(Fminibuffer_complete_word): Ditto.
(Fminibuffer_complete_word): Ditto.
(read_minibuf): Conditionally insert prompt into
buffer instead of handling prompts specially. Change other
functions accordingly. All such code is in #if PROMPT_IN_BUFFER.
(read_minibuf): Set MUST_BE_UPDATED_P instead of
building frame matrix.
(read_minibuf): FRAME_LEFT_SCROLL_BAR_WIDTH removed.
(read_minibuf): Build frame matrix.
Diffstat (limited to 'src')
| -rw-r--r-- | src/minibuf.c | 114 |
1 files changed, 99 insertions, 15 deletions
diff --git a/src/minibuf.c b/src/minibuf.c index f56e609b8c2..8c79b9edf07 100644 --- a/src/minibuf.c +++ b/src/minibuf.c | |||
| @@ -40,29 +40,37 @@ extern int quit_char; | |||
| 40 | invocation, the next element is used for a recursive minibuffer | 40 | invocation, the next element is used for a recursive minibuffer |
| 41 | invocation, etc. The list is extended at the end as deeper | 41 | invocation, etc. The list is extended at the end as deeper |
| 42 | minibuffer recursions are encountered. */ | 42 | minibuffer recursions are encountered. */ |
| 43 | |||
| 43 | Lisp_Object Vminibuffer_list; | 44 | Lisp_Object Vminibuffer_list; |
| 44 | 45 | ||
| 45 | /* Data to remember during recursive minibuffer invocations */ | 46 | /* Data to remember during recursive minibuffer invocations */ |
| 47 | |||
| 46 | Lisp_Object minibuf_save_list; | 48 | Lisp_Object minibuf_save_list; |
| 47 | 49 | ||
| 48 | /* Depth in minibuffer invocations. */ | 50 | /* Depth in minibuffer invocations. */ |
| 51 | |||
| 49 | int minibuf_level; | 52 | int minibuf_level; |
| 50 | 53 | ||
| 51 | /* Nonzero means display completion help for invalid input. */ | 54 | /* Nonzero means display completion help for invalid input. */ |
| 55 | |||
| 52 | int auto_help; | 56 | int auto_help; |
| 53 | 57 | ||
| 54 | /* The maximum length of a minibuffer history. */ | 58 | /* The maximum length of a minibuffer history. */ |
| 59 | |||
| 55 | Lisp_Object Qhistory_length, Vhistory_length; | 60 | Lisp_Object Qhistory_length, Vhistory_length; |
| 56 | 61 | ||
| 57 | /* Fread_minibuffer leaves the input here as a string. */ | 62 | /* Fread_minibuffer leaves the input here as a string. */ |
| 63 | |||
| 58 | Lisp_Object last_minibuf_string; | 64 | Lisp_Object last_minibuf_string; |
| 59 | 65 | ||
| 60 | /* Nonzero means let functions called when within a minibuffer | 66 | /* Nonzero means let functions called when within a minibuffer |
| 61 | invoke recursive minibuffers (to read arguments, or whatever) */ | 67 | invoke recursive minibuffers (to read arguments, or whatever) */ |
| 68 | |||
| 62 | int enable_recursive_minibuffers; | 69 | int enable_recursive_minibuffers; |
| 63 | 70 | ||
| 64 | /* Nonzero means don't ignore text properties | 71 | /* Nonzero means don't ignore text properties |
| 65 | in Fread_from_minibuffer. */ | 72 | in Fread_from_minibuffer. */ |
| 73 | |||
| 66 | int minibuffer_allow_text_properties; | 74 | int minibuffer_allow_text_properties; |
| 67 | 75 | ||
| 68 | /* help-form is bound to this while in the minibuffer. */ | 76 | /* help-form is bound to this while in the minibuffer. */ |
| @@ -109,6 +117,7 @@ static Lisp_Object last_exact_completion; | |||
| 109 | 117 | ||
| 110 | /* Non-nil means it is the window for C-M-v to scroll | 118 | /* Non-nil means it is the window for C-M-v to scroll |
| 111 | when the minibuffer is selected. */ | 119 | when the minibuffer is selected. */ |
| 120 | |||
| 112 | extern Lisp_Object Vminibuf_scroll_window; | 121 | extern Lisp_Object Vminibuf_scroll_window; |
| 113 | 122 | ||
| 114 | extern Lisp_Object Voverriding_local_map; | 123 | extern Lisp_Object Voverriding_local_map; |
| @@ -120,6 +129,15 @@ Lisp_Object Qminibuffer_default; | |||
| 120 | Lisp_Object Qcurrent_input_method, Qactivate_input_method; | 129 | Lisp_Object Qcurrent_input_method, Qactivate_input_method; |
| 121 | 130 | ||
| 122 | 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 | |||
| 123 | 141 | ||
| 124 | /* Put minibuf on currently selected frame's minibuffer. | 142 | /* Put minibuf on currently selected frame's minibuffer. |
| 125 | We do this whenever the user starts a new minibuffer | 143 | We do this whenever the user starts a new minibuffer |
| @@ -181,6 +199,8 @@ without invoking the usual minibuffer commands.") | |||
| 181 | return window; | 199 | return window; |
| 182 | } | 200 | } |
| 183 | 201 | ||
| 202 | #include <stdio.h> | ||
| 203 | |||
| 184 | 204 | ||
| 185 | /* Actual minibuffer invocation. */ | 205 | /* Actual minibuffer invocation. */ |
| 186 | 206 | ||
| @@ -228,6 +248,9 @@ read_minibuf (map, initial, prompt, backup_n, expflag, | |||
| 228 | Lisp_Object mini_frame, ambient_dir, minibuffer, input_method; | 248 | Lisp_Object mini_frame, ambient_dir, minibuffer, input_method; |
| 229 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; | 249 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; |
| 230 | Lisp_Object enable_multibyte; | 250 | Lisp_Object enable_multibyte; |
| 251 | #if !NO_PROMPT_IN_BUFFER | ||
| 252 | extern Lisp_Object Qinvisible, Qintangible, Qread_only, Qfront_sticky; | ||
| 253 | #endif | ||
| 231 | 254 | ||
| 232 | specbind (Qminibuffer_default, defalt); | 255 | specbind (Qminibuffer_default, defalt); |
| 233 | 256 | ||
| @@ -297,6 +320,11 @@ read_minibuf (map, initial, prompt, backup_n, expflag, | |||
| 297 | Fcons (Vminibuffer_history_position, | 320 | Fcons (Vminibuffer_history_position, |
| 298 | Fcons (Vminibuffer_history_variable, | 321 | Fcons (Vminibuffer_history_variable, |
| 299 | minibuf_save_list)))))); | 322 | minibuf_save_list)))))); |
| 323 | #if !NO_PROMPT_IN_BUFFER | ||
| 324 | minibuf_save_list | ||
| 325 | = Fcons (current_buffer->minibuffer_prompt_length, | ||
| 326 | minibuf_save_list); | ||
| 327 | #endif | ||
| 300 | 328 | ||
| 301 | record_unwind_protect (read_minibuf_unwind, Qnil); | 329 | record_unwind_protect (read_minibuf_unwind, Qnil); |
| 302 | minibuf_level++; | 330 | minibuf_level++; |
| @@ -361,6 +389,9 @@ read_minibuf (map, initial, prompt, backup_n, expflag, | |||
| 361 | 389 | ||
| 362 | Fmake_local_variable (Qprint_escape_newlines); | 390 | Fmake_local_variable (Qprint_escape_newlines); |
| 363 | print_escape_newlines = 1; | 391 | print_escape_newlines = 1; |
| 392 | #if !NO_PROMPT_IN_BUFFER | ||
| 393 | XSETFASTINT (current_buffer->minibuffer_prompt_length, 0); | ||
| 394 | #endif | ||
| 364 | 395 | ||
| 365 | /* Erase the buffer. */ | 396 | /* Erase the buffer. */ |
| 366 | { | 397 | { |
| @@ -370,6 +401,25 @@ read_minibuf (map, initial, prompt, backup_n, expflag, | |||
| 370 | unbind_to (count1, Qnil); | 401 | unbind_to (count1, Qnil); |
| 371 | } | 402 | } |
| 372 | 403 | ||
| 404 | if (!NILP (current_buffer->enable_multibyte_characters) | ||
| 405 | && ! STRING_MULTIBYTE (minibuf_prompt)) | ||
| 406 | minibuf_prompt = Fstring_make_multibyte (minibuf_prompt); | ||
| 407 | |||
| 408 | #if !NO_PROMPT_IN_BUFFER | ||
| 409 | /* Insert the prompt, record where it ends. */ | ||
| 410 | Finsert (1, &minibuf_prompt); | ||
| 411 | XSETFASTINT (current_buffer->minibuffer_prompt_length, PT); | ||
| 412 | if (PT > BEG) | ||
| 413 | { | ||
| 414 | Fput_text_property (make_number (BEG), make_number (PT - 1), | ||
| 415 | Qfront_sticky, Qt, Qnil); | ||
| 416 | Fput_text_property (make_number (BEG), make_number (PT - 1), | ||
| 417 | Qread_only, Qt, Qnil); | ||
| 418 | Fput_text_property (make_number (PT - 1), make_number (Z), | ||
| 419 | Qrear_nonsticky, Qt, Qnil); | ||
| 420 | } | ||
| 421 | #endif | ||
| 422 | |||
| 373 | /* If appropriate, copy enable-multibyte-characters into the minibuffer. */ | 423 | /* If appropriate, copy enable-multibyte-characters into the minibuffer. */ |
| 374 | if (inherit_input_method) | 424 | if (inherit_input_method) |
| 375 | current_buffer->enable_multibyte_characters = enable_multibyte; | 425 | current_buffer->enable_multibyte_characters = enable_multibyte; |
| @@ -385,6 +435,7 @@ read_minibuf (map, initial, prompt, backup_n, expflag, | |||
| 385 | echo_area_glyphs = 0; | 435 | echo_area_glyphs = 0; |
| 386 | /* This is in case the minibuffer-setup-hook calls Fsit_for. */ | 436 | /* This is in case the minibuffer-setup-hook calls Fsit_for. */ |
| 387 | previous_echo_glyphs = 0; | 437 | previous_echo_glyphs = 0; |
| 438 | echo_area_message = previous_echo_area_message = Qnil, | ||
| 388 | 439 | ||
| 389 | current_buffer->keymap = map; | 440 | current_buffer->keymap = map; |
| 390 | 441 | ||
| @@ -392,10 +443,6 @@ read_minibuf (map, initial, prompt, backup_n, expflag, | |||
| 392 | if (STRINGP (input_method) && !NILP (Ffboundp (Qactivate_input_method))) | 443 | if (STRINGP (input_method) && !NILP (Ffboundp (Qactivate_input_method))) |
| 393 | call1 (Qactivate_input_method, input_method); | 444 | call1 (Qactivate_input_method, input_method); |
| 394 | 445 | ||
| 395 | if (!NILP (current_buffer->enable_multibyte_characters) | ||
| 396 | && ! STRING_MULTIBYTE (minibuf_prompt)) | ||
| 397 | minibuf_prompt = Fstring_make_multibyte (minibuf_prompt); | ||
| 398 | |||
| 399 | /* Run our hook, but not if it is empty. | 446 | /* Run our hook, but not if it is empty. |
| 400 | (run-hooks would do nothing if it is empty, | 447 | (run-hooks would do nothing if it is empty, |
| 401 | but it's important to save time here in the usual case). */ | 448 | but it's important to save time here in the usual case). */ |
| @@ -407,12 +454,12 @@ read_minibuf (map, initial, prompt, backup_n, expflag, | |||
| 407 | 454 | ||
| 408 | /* If cursor is on the minibuffer line, | 455 | /* If cursor is on the minibuffer line, |
| 409 | show the user we have exited by putting it in column 0. */ | 456 | show the user we have exited by putting it in column 0. */ |
| 410 | if ((FRAME_CURSOR_Y (selected_frame) | 457 | if (XWINDOW (minibuf_window)->cursor.vpos >= 0 |
| 411 | >= XFASTINT (XWINDOW (minibuf_window)->top)) | ||
| 412 | && !noninteractive) | 458 | && !noninteractive) |
| 413 | { | 459 | { |
| 414 | FRAME_CURSOR_X (selected_frame) | 460 | XWINDOW (minibuf_window)->cursor.hpos = 0; |
| 415 | = FRAME_LEFT_SCROLL_BAR_WIDTH (selected_frame); | 461 | XWINDOW (minibuf_window)->cursor.x = 0; |
| 462 | XWINDOW (minibuf_window)->must_be_updated_p = 1; | ||
| 416 | update_frame (selected_frame, 1, 1); | 463 | update_frame (selected_frame, 1, 1); |
| 417 | } | 464 | } |
| 418 | 465 | ||
| @@ -545,8 +592,8 @@ get_minibuffer (depth) | |||
| 545 | return buf; | 592 | return buf; |
| 546 | } | 593 | } |
| 547 | 594 | ||
| 548 | /* This function is called on exiting minibuffer, whether normally or not, | 595 | /* This function is called on exiting minibuffer, whether normally or |
| 549 | and it restores the current window, buffer, etc. */ | 596 | not, and it restores the current window, buffer, etc. */ |
| 550 | 597 | ||
| 551 | static Lisp_Object | 598 | static Lisp_Object |
| 552 | read_minibuf_unwind (data) | 599 | read_minibuf_unwind (data) |
| @@ -566,11 +613,16 @@ read_minibuf_unwind (data) | |||
| 566 | minibuf_level--; | 613 | minibuf_level--; |
| 567 | 614 | ||
| 568 | window = minibuf_window; | 615 | window = minibuf_window; |
| 569 | /* To keep things predictable, in case it matters, let's be in the minibuffer | 616 | /* To keep things predictable, in case it matters, let's be in the |
| 570 | when we reset the relevant variables. */ | 617 | minibuffer when we reset the relevant variables. */ |
| 571 | Fset_buffer (XWINDOW (window)->buffer); | 618 | Fset_buffer (XWINDOW (window)->buffer); |
| 572 | 619 | ||
| 573 | /* Restore prompt, etc, from outer minibuffer level. */ | 620 | /* Restore prompt, etc, from outer minibuffer level. */ |
| 621 | #if !NO_PROMPT_IN_BUFFER | ||
| 622 | current_buffer->minibuffer_prompt_length = Fcar (minibuf_save_list); | ||
| 623 | minibuf_save_list = Fcdr (minibuf_save_list); | ||
| 624 | #endif | ||
| 625 | |||
| 574 | minibuf_prompt = Fcar (minibuf_save_list); | 626 | minibuf_prompt = Fcar (minibuf_save_list); |
| 575 | minibuf_save_list = Fcdr (minibuf_save_list); | 627 | minibuf_save_list = Fcdr (minibuf_save_list); |
| 576 | minibuf_prompt_width = XFASTINT (Fcar (minibuf_save_list)); | 628 | minibuf_prompt_width = XFASTINT (Fcar (minibuf_save_list)); |
| @@ -607,7 +659,6 @@ read_minibuf_unwind (data) | |||
| 607 | windows_or_buffers_changed++; | 659 | windows_or_buffers_changed++; |
| 608 | XSETFASTINT (XWINDOW (window)->last_modified, 0); | 660 | XSETFASTINT (XWINDOW (window)->last_modified, 0); |
| 609 | XSETFASTINT (XWINDOW (window)->last_overlay_modified, 0); | 661 | XSETFASTINT (XWINDOW (window)->last_overlay_modified, 0); |
| 610 | |||
| 611 | return Qnil; | 662 | return Qnil; |
| 612 | } | 663 | } |
| 613 | 664 | ||
| @@ -1616,7 +1667,11 @@ a repetition of this command will exit.") | |||
| 1616 | Lisp_Object val; | 1667 | Lisp_Object val; |
| 1617 | 1668 | ||
| 1618 | /* Allow user to specify null string */ | 1669 | /* Allow user to specify null string */ |
| 1670 | #if !NO_PROMPT_IN_BUFFER | ||
| 1671 | if (XFASTINT (current_buffer->minibuffer_prompt_length) == ZV) | ||
| 1672 | #else | ||
| 1619 | if (BEGV == ZV) | 1673 | if (BEGV == ZV) |
| 1674 | #endif | ||
| 1620 | goto exit; | 1675 | goto exit; |
| 1621 | 1676 | ||
| 1622 | if (!NILP (test_completion (Fbuffer_string ()))) | 1677 | if (!NILP (test_completion (Fbuffer_string ()))) |
| @@ -1750,8 +1805,19 @@ Return nil if there is no valid completion, else t.") | |||
| 1750 | UNGCPRO; | 1805 | UNGCPRO; |
| 1751 | } | 1806 | } |
| 1752 | #endif /* Rewritten code */ | 1807 | #endif /* Rewritten code */ |
| 1753 | i_byte = ZV_BYTE - BEGV_BYTE; | 1808 | |
| 1809 | #if !NO_PROMPT_IN_BUFFER | ||
| 1810 | { | ||
| 1811 | int prompt_end_charpos, prompt_end_bytepos; | ||
| 1812 | prompt_end_charpos = XFASTINT (current_buffer->minibuffer_prompt_length); | ||
| 1813 | prompt_end_bytepos = CHAR_TO_BYTE (prompt_end_charpos); | ||
| 1814 | i = ZV - prompt_end_charpos; | ||
| 1815 | i_byte = ZV_BYTE - prompt_end_bytepos; | ||
| 1816 | } | ||
| 1817 | #else | ||
| 1754 | i = ZV - BEGV; | 1818 | i = ZV - BEGV; |
| 1819 | i_byte = ZV_BYTE - BEGV_BYTE; | ||
| 1820 | #endif | ||
| 1755 | 1821 | ||
| 1756 | /* If completion finds next char not unique, | 1822 | /* If completion finds next char not unique, |
| 1757 | consider adding a space or a hyphen. */ | 1823 | consider adding a space or a hyphen. */ |
| @@ -1801,7 +1867,11 @@ Return nil if there is no valid completion, else t.") | |||
| 1801 | 1867 | ||
| 1802 | /* If got no characters, print help for user. */ | 1868 | /* If got no characters, print help for user. */ |
| 1803 | 1869 | ||
| 1804 | if (i_byte == ZV_BYTE - BEGV_BYTE) | 1870 | #if !NO_PROMPT_IN_BUFFER |
| 1871 | if (i == ZV - XFASTINT (current_buffer->minibuffer_prompt_length)) | ||
| 1872 | #else | ||
| 1873 | if (i == ZV - BEGV) | ||
| 1874 | #endif | ||
| 1805 | { | 1875 | { |
| 1806 | if (auto_help) | 1876 | if (auto_help) |
| 1807 | Fminibuffer_completion_help (); | 1877 | Fminibuffer_completion_help (); |
| @@ -2009,6 +2079,7 @@ DEFUN ("minibuffer-completion-help", Fminibuffer_completion_help, Sminibuffer_co | |||
| 2009 | Vminibuffer_completion_predicate, | 2079 | Vminibuffer_completion_predicate, |
| 2010 | Qt); | 2080 | Qt); |
| 2011 | echo_area_glyphs = 0; | 2081 | echo_area_glyphs = 0; |
| 2082 | echo_area_message = Qnil; | ||
| 2012 | 2083 | ||
| 2013 | if (NILP (completions)) | 2084 | if (NILP (completions)) |
| 2014 | { | 2085 | { |
| @@ -2062,7 +2133,11 @@ DEFUN ("minibuffer-prompt-width", Fminibuffer_prompt_width, | |||
| 2062 | () | 2133 | () |
| 2063 | { | 2134 | { |
| 2064 | Lisp_Object width; | 2135 | Lisp_Object width; |
| 2136 | #if !NO_PROMPT_IN_BUFFER | ||
| 2137 | XSETFASTINT (width, current_buffer->minibuffer_prompt_length); | ||
| 2138 | #else | ||
| 2065 | XSETFASTINT (width, minibuf_prompt_width); | 2139 | XSETFASTINT (width, minibuf_prompt_width); |
| 2140 | #endif | ||
| 2066 | return width; | 2141 | return width; |
| 2067 | } | 2142 | } |
| 2068 | 2143 | ||
| @@ -2177,6 +2252,15 @@ syms_of_minibuf () | |||
| 2177 | Qactivate_input_method = intern ("activate-input-method"); | 2252 | Qactivate_input_method = intern ("activate-input-method"); |
| 2178 | staticpro (&Qactivate_input_method); | 2253 | staticpro (&Qactivate_input_method); |
| 2179 | 2254 | ||
| 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 | |||
| 2180 | DEFVAR_LISP ("read-buffer-function", &Vread_buffer_function, | 2264 | DEFVAR_LISP ("read-buffer-function", &Vread_buffer_function, |
| 2181 | "If this is non-nil, `read-buffer' does its work by calling this function."); | 2265 | "If this is non-nil, `read-buffer' does its work by calling this function."); |
| 2182 | Vread_buffer_function = Qnil; | 2266 | Vread_buffer_function = Qnil; |