Mercurial > emacs
comparison src/minibuf.c @ 25658:a9f38bb7f815
(read_minibuf_unwind): Call resize_mini_window with
new parameter.
(read_minibuf): Use prompt_end_charpos instead
of minibuffer_prompt_length.
(read_minibuf_unwind): Ditto.
(Fminibuffer_complete_and_exit): Ditto.
(Fminibuffer_complete_word): Ditto.
(Fminibuffer_prompt_end): Ditto.
(read_minibuf): Return mini-buffer contents
without the prompt.
(read_minibuf): Set minibuf_prompt_width to the
current column after inserting prompt.
(Fminibuffer_prompt_width): Return minibuf_prompt_width.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Sun, 12 Sep 1999 20:21:55 +0000 |
parents | 7f8ebd701925 |
children | b8bc6e792b2f |
comparison
equal
deleted
inserted
replaced
25657:2e9b26a83bfa | 25658:a9f38bb7f815 |
---|---|
310 Fcons (Vcurrent_prefix_arg, | 310 Fcons (Vcurrent_prefix_arg, |
311 Fcons (Vminibuffer_history_position, | 311 Fcons (Vminibuffer_history_position, |
312 Fcons (Vminibuffer_history_variable, | 312 Fcons (Vminibuffer_history_variable, |
313 minibuf_save_list)))))); | 313 minibuf_save_list)))))); |
314 minibuf_save_list | 314 minibuf_save_list |
315 = Fcons (current_buffer->minibuffer_prompt_length, | 315 = Fcons (current_buffer->prompt_end_charpos, |
316 minibuf_save_list); | 316 minibuf_save_list); |
317 | 317 |
318 record_unwind_protect (read_minibuf_unwind, Qnil); | 318 record_unwind_protect (read_minibuf_unwind, Qnil); |
319 minibuf_level++; | 319 minibuf_level++; |
320 | 320 |
321 /* Now that we can restore all those variables, start changing them. */ | 321 /* Now that we can restore all those variables, start changing them. */ |
322 | 322 |
323 minibuf_prompt_width = 0; /* xdisp.c puts in the right value. */ | 323 minibuf_prompt_width = 0; |
324 minibuf_prompt = Fcopy_sequence (prompt); | 324 minibuf_prompt = Fcopy_sequence (prompt); |
325 Vminibuffer_history_position = histpos; | 325 Vminibuffer_history_position = histpos; |
326 Vminibuffer_history_variable = histvar; | 326 Vminibuffer_history_variable = histvar; |
327 Vhelp_form = Vminibuffer_help_form; | 327 Vhelp_form = Vminibuffer_help_form; |
328 | 328 |
376 Fselect_window (minibuf_window); | 376 Fselect_window (minibuf_window); |
377 XSETFASTINT (XWINDOW (minibuf_window)->hscroll, 0); | 377 XSETFASTINT (XWINDOW (minibuf_window)->hscroll, 0); |
378 | 378 |
379 Fmake_local_variable (Qprint_escape_newlines); | 379 Fmake_local_variable (Qprint_escape_newlines); |
380 print_escape_newlines = 1; | 380 print_escape_newlines = 1; |
381 XSETFASTINT (current_buffer->minibuffer_prompt_length, 0); | 381 XSETFASTINT (current_buffer->prompt_end_charpos, 0); |
382 | 382 |
383 /* Erase the buffer. */ | 383 /* Erase the buffer. */ |
384 { | 384 { |
385 int count1 = specpdl_ptr - specpdl; | 385 int count1 = specpdl_ptr - specpdl; |
386 specbind (Qinhibit_read_only, Qt); | 386 specbind (Qinhibit_read_only, Qt); |
392 && ! STRING_MULTIBYTE (minibuf_prompt)) | 392 && ! STRING_MULTIBYTE (minibuf_prompt)) |
393 minibuf_prompt = Fstring_make_multibyte (minibuf_prompt); | 393 minibuf_prompt = Fstring_make_multibyte (minibuf_prompt); |
394 | 394 |
395 /* Insert the prompt, record where it ends. */ | 395 /* Insert the prompt, record where it ends. */ |
396 Finsert (1, &minibuf_prompt); | 396 Finsert (1, &minibuf_prompt); |
397 XSETFASTINT (current_buffer->minibuffer_prompt_length, PT); | 397 XSETFASTINT (current_buffer->prompt_end_charpos, PT); |
398 if (PT > BEG) | 398 if (PT > BEG) |
399 { | 399 { |
400 Fput_text_property (make_number (BEG), make_number (PT), | 400 Fput_text_property (make_number (BEG), make_number (PT), |
401 Qfront_sticky, Qt, Qnil); | 401 Qfront_sticky, Qt, Qnil); |
402 Fput_text_property (make_number (BEG), make_number (PT), | 402 Fput_text_property (make_number (BEG), make_number (PT), |
403 Qrear_nonsticky, Qt, Qnil); | 403 Qrear_nonsticky, Qt, Qnil); |
404 Fput_text_property (make_number (BEG), make_number (PT), | 404 Fput_text_property (make_number (BEG), make_number (PT), |
405 Qread_only, Qt, Qnil); | 405 Qread_only, Qt, Qnil); |
406 } | 406 } |
407 | |
408 minibuf_prompt_width = current_column (); | |
407 | 409 |
408 /* If appropriate, copy enable-multibyte-characters into the minibuffer. */ | 410 /* If appropriate, copy enable-multibyte-characters into the minibuffer. */ |
409 if (inherit_input_method) | 411 if (inherit_input_method) |
410 current_buffer->enable_multibyte_characters = enable_multibyte; | 412 current_buffer->enable_multibyte_characters = enable_multibyte; |
411 | 413 |
446 rif->flush_display (XFRAME (XWINDOW (minibuf_window)->frame)); | 448 rif->flush_display (XFRAME (XWINDOW (minibuf_window)->frame)); |
447 } | 449 } |
448 | 450 |
449 /* Make minibuffer contents into a string. */ | 451 /* Make minibuffer contents into a string. */ |
450 Fset_buffer (minibuffer); | 452 Fset_buffer (minibuffer); |
451 val = make_buffer_string (1, Z, allow_props); | 453 val = make_buffer_string (current_buffer->prompt_end_charpos, |
454 Z, allow_props); | |
452 | 455 |
453 /* VAL is the string of minibuffer text. */ | 456 /* VAL is the string of minibuffer text. */ |
454 | 457 |
455 last_minibuf_string = val; | 458 last_minibuf_string = val; |
456 | 459 |
599 /* To keep things predictable, in case it matters, let's be in the | 602 /* To keep things predictable, in case it matters, let's be in the |
600 minibuffer when we reset the relevant variables. */ | 603 minibuffer when we reset the relevant variables. */ |
601 Fset_buffer (XWINDOW (window)->buffer); | 604 Fset_buffer (XWINDOW (window)->buffer); |
602 | 605 |
603 /* Restore prompt, etc, from outer minibuffer level. */ | 606 /* Restore prompt, etc, from outer minibuffer level. */ |
604 current_buffer->minibuffer_prompt_length = Fcar (minibuf_save_list); | 607 current_buffer->prompt_end_charpos = Fcar (minibuf_save_list); |
605 minibuf_save_list = Fcdr (minibuf_save_list); | 608 minibuf_save_list = Fcdr (minibuf_save_list); |
606 | 609 |
607 minibuf_prompt = Fcar (minibuf_save_list); | 610 minibuf_prompt = Fcar (minibuf_save_list); |
608 minibuf_save_list = Fcdr (minibuf_save_list); | 611 minibuf_save_list = Fcdr (minibuf_save_list); |
609 minibuf_prompt_width = XFASTINT (Fcar (minibuf_save_list)); | 612 minibuf_prompt_width = XFASTINT (Fcar (minibuf_save_list)); |
637 } | 640 } |
638 | 641 |
639 /* When we get to the outmost level, make sure we resize the | 642 /* When we get to the outmost level, make sure we resize the |
640 mini-window back to its normal size. */ | 643 mini-window back to its normal size. */ |
641 if (minibuf_level == 0) | 644 if (minibuf_level == 0) |
642 resize_mini_window (XWINDOW (window)); | 645 resize_mini_window (XWINDOW (window), 0); |
643 | 646 |
644 /* Make sure minibuffer window is erased, not ignored. */ | 647 /* Make sure minibuffer window is erased, not ignored. */ |
645 windows_or_buffers_changed++; | 648 windows_or_buffers_changed++; |
646 XSETFASTINT (XWINDOW (window)->last_modified, 0); | 649 XSETFASTINT (XWINDOW (window)->last_modified, 0); |
647 XSETFASTINT (XWINDOW (window)->last_overlay_modified, 0); | 650 XSETFASTINT (XWINDOW (window)->last_overlay_modified, 0); |
1651 { | 1654 { |
1652 register int i; | 1655 register int i; |
1653 Lisp_Object val; | 1656 Lisp_Object val; |
1654 | 1657 |
1655 /* Allow user to specify null string */ | 1658 /* Allow user to specify null string */ |
1656 if (XFASTINT (current_buffer->minibuffer_prompt_length) == ZV) | 1659 if (XFASTINT (current_buffer->prompt_end_charpos) == ZV) |
1657 goto exit; | 1660 goto exit; |
1658 | 1661 |
1659 if (!NILP (test_completion (Fbuffer_string ()))) | 1662 if (!NILP (test_completion (Fbuffer_string ()))) |
1660 goto exit; | 1663 goto exit; |
1661 | 1664 |
1788 } | 1791 } |
1789 #endif /* Rewritten code */ | 1792 #endif /* Rewritten code */ |
1790 | 1793 |
1791 { | 1794 { |
1792 int prompt_end_charpos, prompt_end_bytepos; | 1795 int prompt_end_charpos, prompt_end_bytepos; |
1793 prompt_end_charpos = XFASTINT (current_buffer->minibuffer_prompt_length); | 1796 prompt_end_charpos = XFASTINT (current_buffer->prompt_end_charpos); |
1794 prompt_end_bytepos = CHAR_TO_BYTE (prompt_end_charpos); | 1797 prompt_end_bytepos = CHAR_TO_BYTE (prompt_end_charpos); |
1795 i = ZV - prompt_end_charpos; | 1798 i = ZV - prompt_end_charpos; |
1796 i_byte = ZV_BYTE - prompt_end_bytepos; | 1799 i_byte = ZV_BYTE - prompt_end_bytepos; |
1797 } | 1800 } |
1798 | 1801 |
1842 } | 1845 } |
1843 } | 1846 } |
1844 | 1847 |
1845 /* If got no characters, print help for user. */ | 1848 /* If got no characters, print help for user. */ |
1846 | 1849 |
1847 if (i == ZV - XFASTINT (current_buffer->minibuffer_prompt_length)) | 1850 if (i == ZV - XFASTINT (current_buffer->prompt_end_charpos)) |
1848 { | 1851 { |
1849 if (auto_help) | 1852 if (auto_help) |
1850 Fminibuffer_completion_help (); | 1853 Fminibuffer_completion_help (); |
1851 return Qnil; | 1854 return Qnil; |
1852 } | 1855 } |
2099 return Fcopy_sequence (minibuf_prompt); | 2102 return Fcopy_sequence (minibuf_prompt); |
2100 } | 2103 } |
2101 | 2104 |
2102 DEFUN ("minibuffer-prompt-width", Fminibuffer_prompt_width, | 2105 DEFUN ("minibuffer-prompt-width", Fminibuffer_prompt_width, |
2103 Sminibuffer_prompt_width, 0, 0, 0, | 2106 Sminibuffer_prompt_width, 0, 0, 0, |
2104 "Return the display width of the minibuffer prompt.\n\ | 2107 "Return the display width of the minibuffer prompt.") |
2105 Return 0 if current buffer is not a mini-buffer.") | |
2106 () | 2108 () |
2107 { | 2109 { |
2108 Lisp_Object width; | 2110 return make_number (minibuf_prompt_width); |
2109 if (NILP (current_buffer->minibuffer_prompt_length)) | |
2110 width = make_number (0); | |
2111 else | |
2112 width = make_number (current_buffer->minibuffer_prompt_length); | |
2113 return width; | |
2114 } | 2111 } |
2115 | 2112 |
2116 | 2113 |
2117 DEFUN ("minibuffer-prompt-end", Fminibuffer_prompt_end, | 2114 DEFUN ("minibuffer-prompt-end", Fminibuffer_prompt_end, |
2118 Sminibuffer_prompt_end, 0, 0, 0, | 2115 Sminibuffer_prompt_end, 0, 0, 0, |
2119 "Return the end buffer position of the mini-buffer prompt.\n\ | 2116 "Return the end buffer position of the mini-buffer prompt.\n\ |
2120 Value is 0 if current buffer is not a mini-buffer.") | 2117 Value is 0 if current buffer is not a mini-buffer.") |
2121 () | 2118 () |
2122 { | 2119 { |
2123 return (NILP (current_buffer->minibuffer_prompt_length) | 2120 return (NILP (current_buffer->prompt_end_charpos) |
2124 ? make_number (0) | 2121 ? make_number (0) |
2125 : make_number (current_buffer->minibuffer_prompt_length)); | 2122 : make_number (current_buffer->prompt_end_charpos)); |
2126 } | 2123 } |
2127 | 2124 |
2128 | 2125 |
2129 | 2126 |
2130 /* Temporarily display the string M at the end of the current | 2127 /* Temporarily display the string M at the end of the current |