X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/07d402c8dbd99e2da1c365d26ce2b3f18a3a4a2b..e0b5b76c4ed26258e148a84757d1b80ce168da70:/src/minibuf.c?ds=sidebyside diff --git a/src/minibuf.c b/src/minibuf.c index f99bffdf55..0db5e62677 100644 --- a/src/minibuf.c +++ b/src/minibuf.c @@ -23,6 +23,7 @@ Boston, MA 02111-1307, USA. */ #include "lisp.h" #include "commands.h" #include "buffer.h" +#include "charset.h" #include "dispextern.h" #include "frame.h" #include "window.h" @@ -322,7 +323,7 @@ read_minibuf (map, initial, prompt, backup_n, expflag, histvar, histpos) { Finsert (1, &initial); if (!NILP (backup_n) && INTEGERP (backup_n)) - Fforward_char (backup_n); + Fgoto_char (make_number (PT + XFASTINT (backup_n))); } echo_area_glyphs = 0; @@ -921,6 +922,7 @@ scmp (s1, s2, len) int len; { register int l = len; + register unsigned char *start = s1; if (completion_ignore_case) { @@ -935,7 +937,15 @@ scmp (s1, s2, len) if (l == 0) return -1; else - return len - l; + { + int match = len - l; + + /* Now *--S1 is the unmatching byte. If it is in the middle of + multi-byte form, we must say that the multi-byte character + there doesn't match. */ + while (match && *--s1 >= 0xA0) match--; + return match; + } } DEFUN ("all-completions", Fall_completions, Sall_completions, 2, 4, 0, @@ -1161,38 +1171,6 @@ DEFUN ("completing-read", Fcompleting_read, Scompleting_read, 2, 6, 0, return unbind_to (count, val); } -/* Temporarily display the string M at the end of the current - minibuffer contents. This is used to display things like - "[No Match]" when the user requests a completion for a prefix - that has no possible completions, and other quick, unobtrusive - messages. */ - -temp_echo_area_glyphs (m) - char *m; -{ - int osize = ZV; - int opoint = PT; - Lisp_Object oinhibit; - oinhibit = Vinhibit_quit; - - /* Clear out any old echo-area message to make way for our new thing. */ - message (0); - - SET_PT (osize); - insert_string (m); - SET_PT (opoint); - Vinhibit_quit = Qt; - Fsit_for (make_number (2), Qnil, Qnil); - del_range (osize, ZV); - SET_PT (opoint); - if (!NILP (Vquit_flag)) - { - Vquit_flag = Qnil; - Vunread_command_events = Fcons (make_number (quit_char), Qnil); - } - Vinhibit_quit = oinhibit; -} - Lisp_Object Fminibuffer_completion_help (); Lisp_Object assoc_for_completion (); /* A subroutine of Fintern_soft. */ @@ -1568,13 +1546,22 @@ Return nil if there is no valid completion, else t.") /* Now find first word-break in the stuff found by completion. i gets index in string of where to stop completing. */ + { + int len, c; - completion_string = XSTRING (completion)->data; - - for (; i < XSTRING (completion)->size; i++) - if (SYNTAX (completion_string[i]) != Sword) break; - if (i < XSTRING (completion)->size) - i = i + 1; + completion_string = XSTRING (completion)->data; + for (; i < XSTRING (completion)->size; i += len) + { + c = STRING_CHAR_AND_LENGTH (completion_string + i, + XSTRING (completion)->size - i, + len); + if (SYNTAX (c) != Sword) + { + i += len; + break; + } + } + } /* If got no characters, print help for user. */ @@ -1798,6 +1785,50 @@ DEFUN ("minibuffer-prompt-width", Fminibuffer_prompt_width, return width; } +/* Temporarily display the string M at the end of the current + minibuffer contents. This is used to display things like + "[No Match]" when the user requests a completion for a prefix + that has no possible completions, and other quick, unobtrusive + messages. */ + +temp_echo_area_glyphs (m) + char *m; +{ + int osize = ZV; + int opoint = PT; + Lisp_Object oinhibit; + oinhibit = Vinhibit_quit; + + /* Clear out any old echo-area message to make way for our new thing. */ + message (0); + + SET_PT (osize); + insert_string (m); + SET_PT (opoint); + Vinhibit_quit = Qt; + Fsit_for (make_number (2), Qnil, Qnil); + del_range (osize, ZV); + SET_PT (opoint); + if (!NILP (Vquit_flag)) + { + Vquit_flag = Qnil; + Vunread_command_events = Fcons (make_number (quit_char), Qnil); + } + Vinhibit_quit = oinhibit; +} + +DEFUN ("minibuffer-message", Fminibuffer_message, Sminibuffer_message, + 1, 1, 0, + "Temporarily display STRING at the end of the minibuffer.\n\ +The text is displayed for two seconds,\n\ +or until the next input event arrives, whichever comes first.") + (string) + Lisp_Object string; +{ + temp_echo_area_glyphs (XSTRING (string)->data); + return Qnil; +} + init_minibuf_once () { Vminibuffer_list = Qnil; @@ -1915,7 +1946,8 @@ is added with\n\ Vminibuffer_history_position = Qnil; DEFVAR_BOOL ("minibuffer-auto-raise", &minibuffer_auto_raise, - "*Non-nil means entering the minibuffer raises the minibuffer's frame."); + "*Non-nil means entering the minibuffer raises the minibuffer's frame.\n\ +Some uses of the echo area also raise that frame (since they use it too)."); minibuffer_auto_raise = 0; DEFVAR_LISP ("completion-regexp-list", &Vcompletion_regexp_list, @@ -1947,6 +1979,7 @@ is added with\n\ defsubr (&Sself_insert_and_exit); defsubr (&Sexit_minibuffer); + defsubr (&Sminibuffer_message); } keys_of_minibuf ()