diff --git a/complete.c b/complete.c index f564a47..1cf65c1 100644 --- a/complete.c +++ b/complete.c @@ -432,7 +432,6 @@ int rl_sort_completion_matches = 1; /* Local variable states what happened during the last completion attempt. */ static int completion_changed_buffer; -static int last_completion_failed = 0; /* The result of the query to the user about displaying completion matches */ static int completion_y_or_n; @@ -455,12 +454,8 @@ rl_complete (int ignore, int invoking_key) if (rl_inhibit_completion) return (_rl_insert_char (ignore, invoking_key)); -#if 0 - else if (rl_last_func == rl_complete && completion_changed_buffer == 0 && last_completion_failed == 0) -#else else if (rl_last_func == rl_complete && completion_changed_buffer == 0) -#endif - return (rl_complete_internal ('?')); + return (rl_complete_internal ('2')); else if (_rl_complete_show_all) return (rl_complete_internal ('!')); else if (_rl_complete_show_unmodified) @@ -473,7 +468,6 @@ rl_complete (int ignore, int invoking_key) int rl_possible_completions (int ignore, int invoking_key) { - last_completion_failed = 0; rl_completion_invoking_key = invoking_key; return (rl_complete_internal ('?')); } @@ -2047,13 +2041,11 @@ rl_complete_internal (int what_to_do) int start, end, delimiter, found_quote, i, nontrivial_lcd, do_display; char *text, *saved_line_buffer; char quote_char; - int tlen, mlen, saved_last_completion_failed; + int tlen, mlen; complete_sigcleanarg_t cleanarg; /* state to clean up on signal */ RL_SETSTATE(RL_STATE_COMPLETING); - saved_last_completion_failed = last_completion_failed; - set_completion_defaults (what_to_do); saved_line_buffer = rl_line_buffer ? savestring (rl_line_buffer) : (char *)NULL; @@ -2102,7 +2094,6 @@ rl_complete_internal (int what_to_do) rl_ding (); FREE (saved_line_buffer); completion_changed_buffer = 0; - last_completion_failed = 1; RL_UNSETSTATE(RL_STATE_COMPLETING); _rl_reset_completion_state (); return (0); @@ -2118,15 +2109,11 @@ rl_complete_internal (int what_to_do) rl_ding (); FREE (saved_line_buffer); completion_changed_buffer = 0; - last_completion_failed = 1; RL_UNSETSTATE(RL_STATE_COMPLETING); _rl_reset_completion_state (); return (0); } - if (matches && matches[0] && *matches[0]) - last_completion_failed = 0; - do_display = 0; switch (what_to_do) @@ -2183,10 +2170,9 @@ rl_complete_internal (int what_to_do) insert_all_matches (matches, start, "e_char); break; - case '?': - /* Let's try to insert a single match here if the last completion failed - but this attempt returned a single match. */ - if (saved_last_completion_failed && matches[0] && *matches[0] && matches[1] == 0) + case '2': + /* Let's try to insert a possible single match here. */ + if (matches[0] && *matches[0] && matches[1] == 0) { insert_match (matches[0], start, matches[1] ? MULT_MATCH : SINGLE_MATCH, "e_char); append_to_match (matches[0], delimiter, quote_char, nontrivial_lcd); @@ -2194,6 +2180,7 @@ rl_complete_internal (int what_to_do) } /*FALLTHROUGH*/ + case '?': case '%': /* used by menu_complete */ case '|': /* add this for unconditional display */ do_display = 1; diff --git a/doc/rltech.texi b/doc/rltech.texi index 497cd4d..8b5a628 100644 --- a/doc/rltech.texi +++ b/doc/rltech.texi @@ -1989,7 +1989,11 @@ insert all of the possible completions. @samp{!} means to display all of the possible completions, if there is more than one, as well as performing partial completion. @samp{@@} is similar to @samp{!}, but possible completions are not listed if the possible completions share -a common prefix. +a common prefix. The value @samp{2} lists all completions, except if +there is only a single completion, which it inserts instead; this is +the action performed by invoking standard completion a second time +after the first completion resulted in no matches or more than one +match. @end deftypefun @deftypefun int rl_complete (int ignore, int invoking_key)