]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
i9e: Rename i9e_completer() -> attempt_completion().
authorAndre Noll <maan@tuebingen.mpg.de>
Sat, 19 Apr 2025 09:00:06 +0000 (11:00 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Wed, 23 Apr 2025 19:41:42 +0000 (21:41 +0200)
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.

interactive.c

index 4d48742f686862bb8d5fe8871116925309dbc978..3115d539d414b0569db8cfeed28c52835a44899f 100644 (file)
@@ -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);