📄 minibuf.c
字号:
(){ register int i = do_completion (); switch (i) { case 0: return Qnil; case 1: temp_echo_area_contents(" [Sole completion]"); break; case 3: temp_echo_area_contents(" [Complete, but not unique]"); break; } return Qt;}DEFUN ("minibuffer-complete-and-exit", Fminibuffer_complete_and_exit, Sminibuffer_complete_and_exit, 0, 0, "", "Complete the minibuffer contents, and maybe exit.\n\Exit if the name is valid with no completion needed.\n\If name was completed to a valid match,\n\a repetition of this command will exit.") (){ register int i; /* Allow user to specify null string */ if (BEGV == ZV) goto exit; i = do_completion (); switch (i) { case 1: case 3: goto exit; case 4: if (!NULL (Vminibuffer_completion_confirm)) { temp_echo_area_contents(" [Confirm]"); return Qnil; } else goto exit; default: return Qnil; } exit: Fthrow (Qexit, Qnil); /* NOTREACHED */}DEFUN ("minibuffer-complete-word", Fminibuffer_complete_word, Sminibuffer_complete_word, 0, 0, "", "Complete the minibuffer contents at most a single word.") (){ Lisp_Object completion, tem; register int i; register unsigned char *completion_string; /* We keep calling Fbuffer_string rather than arrange for GC to hold onto a pointer to one of the strings thus made. */ completion = Ftry_completion (Fbuffer_string (), Vminibuffer_completion_table, Vminibuffer_completion_predicate); if (NULL (completion)) { bell (); temp_echo_area_contents (" [No match]"); return Qnil; } if (EQ (completion, Qt)) return Qnil;#if 0 /* How the below code used to look, for reference */ tem = Fbuffer_string (); b = XSTRING (tem)->data; i = ZV - 1 - XSTRING (completion)->size; p = XSTRING (completion)->data; if (i > 0 || 0 <= scmp (b, p, ZV - 1)) { i = 1; /* Set buffer to longest match of buffer tail and completion head. */ while (0 <= scmp (b + i, p, ZV - 1 - i)) i++; del_range (1, i + 1); SET_PT (ZV); }#else /* Rewritten code */ { register unsigned char *buffer_string; int buffer_length, completion_length; tem = Fbuffer_string (); buffer_string = XSTRING (tem)->data; completion_string = XSTRING (completion)->data; buffer_length = XSTRING (tem)->size; /* ie ZV - BEGV */ completion_length = XSTRING (completion)->size; i = buffer_length - completion_length; /* Mly: I don't understand what this is supposed to do AT ALL */ if (i > 0 || 0 <= scmp (buffer_string, completion_string, buffer_length)) { /* Set buffer to longest match of buffer tail and completion head. */ if (i <= 0) i = 1; buffer_string += i; buffer_length -= i; while (0 <= scmp (buffer_string++, completion_string, buffer_length--)) i++; del_range (1, i + 1); SET_PT (ZV); } }#endif /* Rewritten code */ i = ZV - BEGV; /* If completion finds next char not unique, consider adding a space or a hyphen */ if (i == XSTRING (completion)->size) { tem = Ftry_completion (concat2 (Fbuffer_string (), build_string (" ")), Vminibuffer_completion_table, Vminibuffer_completion_predicate); if (XTYPE (tem) == Lisp_String) completion = tem; else { tem = Ftry_completion (concat2 (Fbuffer_string (), build_string ("-")), Vminibuffer_completion_table, Vminibuffer_completion_predicate); if (XTYPE (tem) == Lisp_String) completion = tem; } } /* Now find first word-break in the stuff found by completion. i gets index in string of where to stop completing. */ 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; /* If got no characters, print help for user. */ if (i == ZV - BEGV) { if (completion_auto_help) Fminibuffer_completion_help (); return Qnil; } /* Otherwise insert in minibuffer the chars we got */ Ferase_buffer (); insert (completion_string, i); return Qt;}DEFUN ("display-completion-list", Fdisplay_completion_list, Sdisplay_completion_list, 1, 1, 0, "Display in a buffer the list of completions, COMPLETIONS.\n\Each element may be just a symbol or string\n\or may be a list of two strings to be printed as if concatenated.") (completions) Lisp_Object completions;{ register Lisp_Object tail, elt; register int i; struct buffer *old = current_buffer; /* No GCPRO needed, since (when it matters) every variable points to a non-string that is pointed to by COMPLETIONS. */ set_buffer_internal (XBUFFER (Vstandard_output)); if (NULL (completions)) InsStr ("There are no possible completions of what you have typed."); else { InsStr ("Possible completions are:"); for (tail = completions, i = 0; !NULL (tail); tail = Fcdr (tail), i++) { /* this needs fixing for the case of long completions and/or narrow windows */ /* Sadly, the window it will appear in is not known until after the text has been made. */ if (i & 1) Findent_to (make_number (35), make_number (1)); else Fterpri (Qnil); elt = Fcar (tail); if (CONSP (elt)) { Fprinc (Fcar (elt), Qnil); Fprinc (Fcar (Fcdr (elt)), Qnil); } else Fprinc (elt, Qnil); } } set_buffer_internal (old); return Qnil;}DEFUN ("minibuffer-completion-help", Fminibuffer_completion_help, Sminibuffer_completion_help, 0, 0, "", "Display a list of possible completions of the current minibuffer contents.") (){ Lisp_Object completions; message ("Making completion list..."); completions = Fall_completions (Fbuffer_string (), Vminibuffer_completion_table, Vminibuffer_completion_predicate); echo_area_contents = 0; if (NULL (completions)) { bell (); temp_echo_area_contents (" [No completions]"); } else internal_with_output_to_temp_buffer (" *Completions*", Fdisplay_completion_list, Fsort (completions, Qstring_lessp)); return Qnil;}DEFUN ("self-insert-and-exit", Fself_insert_and_exit, Sself_insert_and_exit, 0, 0, "", "Terminate minibuffer input.") (){ self_insert_internal (last_command_char, 0); Fthrow (Qexit, Qnil);}DEFUN ("exit-minibuffer", Fexit_minibuffer, Sexit_minibuffer, 0, 0, "", "Terminate this minibuffer argument.") (){ Fthrow (Qexit, Qnil);}DEFUN ("minibuffer-depth", Fminibuffer_depth, Sminibuffer_depth, 0, 0, 0, "Return current depth of activations of minibuffer, a nonnegative integer.") (){ return make_number (minibuf_level);}init_minibuf_once (){ Vminibuffer_list = Qnil; staticpro (&Vminibuffer_list);}syms_of_minibuf (){ minibuf_level = 0; minibuf_prompt = 0; minibuf_save_vector_size = 5; minibuf_save_vector = (struct minibuf_save_data *) malloc (5 * sizeof (struct minibuf_save_data)); Qminibuffer_completion_table = intern ("minibuffer-completion-table"); staticpro (&Qminibuffer_completion_table); Qminibuffer_completion_confirm = intern ("minibuffer-completion-confirm"); staticpro (&Qminibuffer_completion_confirm); Qminibuffer_completion_predicate = intern ("minibuffer-completion-predicate"); staticpro (&Qminibuffer_completion_predicate); staticpro (&last_minibuf_string); last_minibuf_string = Qnil; Quser_variable_p = intern ("user-variable-p"); staticpro (&Quser_variable_p); DEFVAR_BOOL ("completion-auto-help", &completion_auto_help, "*Non-nil means automatically provide help for invalid completion input."); completion_auto_help = 1; DEFVAR_BOOL ("completion-ignore-case", &completion_ignore_case, "Non-nil means don't consider case significant in completion."); completion_ignore_case = 0; DEFVAR_BOOL ("enable-recursive-minibuffers", &enable_recursive_minibuffers, "*Non-nil means to allow minibuffers to invoke commands which use\n\recursive minibuffers."); enable_recursive_minibuffers = 0; DEFVAR_LISP ("minibuffer-completion-table", &Vminibuffer_completion_table, "Alist or obarray used for completion in the minibuffer."); Vminibuffer_completion_table = Qnil; DEFVAR_LISP ("minibuffer-completion-predicate", &Vminibuffer_completion_predicate, "Holds PREDICATE argument to completing-read."); Vminibuffer_completion_predicate = Qnil; DEFVAR_LISP ("minibuffer-completion-confirm", &Vminibuffer_completion_confirm, "Non-nil => demand confirmation of completion before exiting minibuffer."); Vminibuffer_completion_confirm = Qnil; DEFVAR_LISP ("minibuffer-help-form", &Vminibuffer_help_form, "Value that help-form takes on inside the minibuffer."); Vminibuffer_help_form = Qnil; defsubr (&Sread_from_minibuffer); defsubr (&Seval_minibuffer); defsubr (&Sread_minibuffer); defsubr (&Sread_string); defsubr (&Sread_command); defsubr (&Sread_variable); defsubr (&Sread_buffer); defsubr (&Sread_no_blanks_input); defsubr (&Sminibuffer_depth); defsubr (&Stry_completion); defsubr (&Sall_completions); defsubr (&Scompleting_read); defsubr (&Sminibuffer_complete); defsubr (&Sminibuffer_complete_word); defsubr (&Sminibuffer_complete_and_exit); defsubr (&Sdisplay_completion_list); defsubr (&Sminibuffer_completion_help); defsubr (&Sself_insert_and_exit); defsubr (&Sexit_minibuffer);}keys_of_minibuf (){ ndefkey (Vminibuffer_local_map, Ctl ('g'), "abort-recursive-edit"); ndefkey (Vminibuffer_local_map, Ctl ('m'), "exit-minibuffer"); ndefkey (Vminibuffer_local_map, Ctl ('j'), "exit-minibuffer"); ndefkey (Vminibuffer_local_ns_map, Ctl ('g'), "abort-recursive-edit"); ndefkey (Vminibuffer_local_ns_map, Ctl ('m'), "exit-minibuffer"); ndefkey (Vminibuffer_local_ns_map, Ctl ('j'), "exit-minibuffer"); ndefkey (Vminibuffer_local_ns_map, ' ', "exit-minibuffer"); ndefkey (Vminibuffer_local_ns_map, '\t', "exit-minibuffer"); ndefkey (Vminibuffer_local_ns_map, '?', "self-insert-and-exit"); ndefkey (Vminibuffer_local_completion_map, Ctl ('g'), "abort-recursive-edit"); ndefkey (Vminibuffer_local_completion_map, Ctl ('m'), "exit-minibuffer"); ndefkey (Vminibuffer_local_completion_map, Ctl ('j'), "exit-minibuffer"); ndefkey (Vminibuffer_local_completion_map, '\t', "minibuffer-complete"); ndefkey (Vminibuffer_local_completion_map, ' ', "minibuffer-complete-word"); ndefkey (Vminibuffer_local_completion_map, '?', "minibuffer-completion-help"); ndefkey (Vminibuffer_local_must_match_map, Ctl ('g'), "abort-recursive-edit"); ndefkey (Vminibuffer_local_must_match_map, Ctl ('m'), "minibuffer-complete-and-exit"); ndefkey (Vminibuffer_local_must_match_map, Ctl ('j'), "minibuffer-complete-and-exit"); ndefkey (Vminibuffer_local_must_match_map, '\t', "minibuffer-complete"); ndefkey (Vminibuffer_local_must_match_map, ' ', "minibuffer-complete-word"); ndefkey (Vminibuffer_local_must_match_map, '?', "minibuffer-completion-help");}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -