From: Andre Noll Date: Sat, 19 Apr 2025 09:00:06 +0000 (+0200) Subject: i9e: Rename i9e_completer() -> attempt_completion(). X-Git-Url: https://git.tuebingen.mpg.de/?a=commitdiff_plain;h=e475c2680988f5e7d3de5330d8b48e03ae587353;p=paraslash.git i9e: Rename i9e_completer() -> attempt_completion(). The old name is confusing since we also have struct i9e_completer, which is a completely different beast. Rewrite the documentation of the function while at it. --- diff --git a/interactive.c b/interactive.c index 4d48742f..3115d539 100644 --- a/interactive.c +++ b/interactive.c @@ -159,25 +159,6 @@ out: return matches[list_index++]; } -/* - * Attempt to complete on the contents of TEXT. START and END bound the - * region of rl_line_buffer that contains the word to complete. TEXT is - * the word to complete. We can use the entire contents of rl_line_buffer - * in case we want to do some simple parsing. Return the array of matches, - * or NULL if there aren't any. - */ -static char **i9e_completer(const char *text, int start, __a_unused int end) -{ - struct i9e_client_info *ici = i9ep->ici; - - if (!ici->completers) - return NULL; - /* Complete on command names if this is the first word in the line. */ - if (start == 0) - return rl_completion_matches(text, command_generator); - return rl_completion_matches(text, completion_generator); -} - /** * Prepare writing to stdout. * @@ -431,6 +412,24 @@ again: goto again; } +/* + * Calls either command_generator() or completion_generator() via + * rl_completion_matches(). May set rl_attempted_completion_over to instruct + * readline to not perform its default completion even if no matches are + * returned. + */ +static char **attempt_completion(const char *text, int start, __a_unused int end) +{ + struct i9e_client_info *ici = i9ep->ici; + + if (!ici->completers) + return NULL; + /* Complete on command names if this is the first word in the line. */ + if (start == 0) + return rl_completion_matches(text, command_generator); + return rl_completion_matches(text, completion_generator); +} + /** * Register the i9e task and initialize readline. * @@ -471,7 +470,7 @@ int i9e_open(struct i9e_client_info *ici, struct sched *s) rl_readline_name = "para_i9e"; rl_basic_word_break_characters = " "; - rl_attempted_completion_function = i9e_completer; + rl_attempted_completion_function = attempt_completion; i9ep->ici = ici; i9ep->stderr_stream = fdopen(ici->fds[2], "w"); setvbuf(i9ep->stderr_stream, NULL, _IONBF, 0);