On Mon, May 05, 2014 at 03:51:37PM -0400, Luiz Capitulino wrote: > On Sun, 27 Apr 2014 17:00:03 +0100 > Hani Benhabiles <kroo...@gmail.com> wrote: > > > Signed-off-by: Hani Benhabiles <h...@linux.com> > > --- > > hmp-commands.hx | 1 + > > hmp.h | 1 + > > monitor.c | 24 +++++++++++++++++------- > > 3 files changed, 19 insertions(+), 7 deletions(-) > > > > diff --git a/hmp-commands.hx b/hmp-commands.hx > > index b3f45d6..ba13997 100644 > > --- a/hmp-commands.hx > > +++ b/hmp-commands.hx > > @@ -15,6 +15,7 @@ ETEXI > > .params = "[cmd]", > > .help = "show the help", > > .mhandler.cmd = do_help_cmd, > > + .command_completion = help_completion, > > }, > > > > STEXI > > diff --git a/hmp.h b/hmp.h > > index 12e21e7..55f78fa 100644 > > --- a/hmp.h > > +++ b/hmp.h > > @@ -98,5 +98,6 @@ void object_del_completion(ReadLineState *rs, int > > nb_args, const char *str); > > void device_add_completion(ReadLineState *rs, int nb_args, const char > > *str); > > void device_del_completion(ReadLineState *rs, int nb_args, const char > > *str); > > void sendkey_completion(ReadLineState *rs, int nb_args, const char *str); > > +void help_completion(ReadLineState *rs, int nb_args, const char *str); > > > > #endif > > diff --git a/monitor.c b/monitor.c > > index 7edfcee..acbbaf8 100644 > > --- a/monitor.c > > +++ b/monitor.c > > @@ -4407,6 +4407,23 @@ void sendkey_completion(ReadLineState *rs, int > > nb_args, const char *str) > > } > > } > > > > +void help_completion(ReadLineState *rs, int nb_args, const char *str) > > +{ > > + int i; > > + size_t len; > > + > > + if (nb_args != 2) { > > + return; > > + } > > + len = strlen(str); > > + readline_set_completion_index(rs, len); > > + for (i = 0; mon_cmds[i].name; i++) { > > + if (!strncmp(str, mon_cmds[i].name, len)) { > > + readline_add_completion(rs, mon_cmds[i].name); > > + } > > + } > > +} > > + > > static void monitor_find_completion_by_table(Monitor *mon, > > const mon_cmd_t *cmd_table, > > char **args, > > @@ -4473,13 +4490,6 @@ static void monitor_find_completion_by_table(Monitor > > *mon, > > readline_set_completion_index(mon->rs, strlen(str)); > > bdrv_iterate(block_completion_it, &mbs); > > break; > > - case 's': > > - case 'S': > > - if (!strcmp(cmd->name, "help|?")) { > > - monitor_find_completion_by_table(mon, cmd_table, > > - &args[1], nb_args - 1); > > - } > > - break; > > default: > > break; > > } > > This breaks auto-completion for: > > (qemu) help info v > > Which would auto-complete "vnc". IIRC, that's one of the reasons we have > monitor_find_completion_by_table().
Thanks for spotting that. Quickly thinking about it, a possible way to solve this is to change command_completion() prototype to be passed the whole args table, and not just a string and then have those "special cases" (like help+info) handled. Better drop patch 02/07 and leave the rest as is for now, I believe. I will send a v2.