Received: from eggs.gnu.org ([2001:4830:134:3::10]:44223) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wi9bg-0008Fd-Ei for qemu-devel@nongnu.org; Wed, 07 May 2014 17:42:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wi9bY-0006kl-PD for qemu-devel@nongnu.org; Wed, 07 May 2014 17:42:28 -0400 Received: from mail-we0-x22c.google.com ([2a00:1450:400c:c03::22c]:34900) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wi9bY-0006jt-IS for qemu-devel@nongnu.org; Wed, 07 May 2014 17:42:20 -0400 Received: by mail-we0-f172.google.com with SMTP id k48so1651867wev.17 for ; Wed, 07 May 2014 14:42:19 -0700 (PDT) Date: Wed, 7 May 2014 22:42:15 +0100 From: Hani Benhabiles Message-ID: <20140507214215.GB22402@Inspiron-3521> References: <1398614409-30792-1-git-send-email-kroosec@gmail.com> <1398614409-30792-3-git-send-email-kroosec@gmail.com> <20140505155137.0889bd32@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20140505155137.0889bd32@redhat.com> Subject: Re: [Qemu-devel] [PATCH 2/7] monitor: Convert help|? to use command_completion. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Luiz Capitulino Cc: qemu-devel@nongnu.org, stefanha@redhat.com On Mon, May 05, 2014 at 03:51:37PM -0400, Luiz Capitulino wrote: > On Sun, 27 Apr 2014 17:00:03 +0100 > Hani Benhabiles wrote: > > > Signed-off-by: Hani Benhabiles > > --- > > 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.