rc

[fork] interactive rc shell
Log | Files | Refs | README | LICENSE

commit f26b1b7d1311c34b1ed4ec29b5d26e3ae421873b
parent a50b93cd6790c95a85c7647829c14a0ccd166f31
Author: Bert Münnich <b.muennich@stagetec.com>
Date:   Fri, 26 Feb 2016 18:32:27 +0100

Always insert single match of explicit complete function

If an explicit complete function has only one match but is used directly after
the default tab completion, than the single match is shown instead of inserted.
The solution is resetting the 'rl_last_func' variable if it is set to
'rl_complete' when using an explicit complete function.

Diffstat:
Medit-readline.c | 16++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/edit-readline.c b/edit-readline.c @@ -111,19 +111,23 @@ static char **rc_completion(const char *text, int start, int end) { return NULL; } -static int rc_complete_command(int count, int key) { - compentry_func = compl_extcmd; +static int expl_complete(rl_compentry_func_t *func, int count, int key) { + if (rl_last_func == rl_complete) + rl_last_func = NULL; + compentry_func = func; return rl_complete(count, key); } +static int rc_complete_command(int count, int key) { + return expl_complete(compl_extcmd, count, key); +} + static int rc_complete_filename(int count, int key) { - compentry_func = rl_filename_completion_function; - return rl_complete(count, key); + return expl_complete(rl_filename_completion_function, count, key); } static int rc_complete_variable(int count, int key) { - compentry_func = compl_var; - return rl_complete(count, key); + return expl_complete(compl_var, count, key); } void *edit_begin(int fd) {