From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39174) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uq3Cr-0005y7-AJ for qemu-devel@nongnu.org; Fri, 21 Jun 2013 11:24:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uq3Cp-0004x7-8v for qemu-devel@nongnu.org; Fri, 21 Jun 2013 11:24:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:23081) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uq3Co-0004x1-QR for qemu-devel@nongnu.org; Fri, 21 Jun 2013 11:24:55 -0400 Date: Fri, 21 Jun 2013 11:24:44 -0400 From: Luiz Capitulino Message-ID: <20130621112444.14891a5f@redhat.com> In-Reply-To: <1371796658-15632-3-git-send-email-xiawenc@linux.vnet.ibm.com> References: <1371796658-15632-1-git-send-email-xiawenc@linux.vnet.ibm.com> <1371796658-15632-3-git-send-email-xiawenc@linux.vnet.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 2/2] monitor: support sub commands in auto completion List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Wenchao Xia Cc: pbonzini@redhat.com, qemu-devel@nongnu.org, armbru@redhat.com On Fri, 21 Jun 2013 14:37:38 +0800 Wenchao Xia wrote: > This patch allow auot completion work normal in sub command case, > "info block [DEVICE]" can auto complete now, by re-enter the completion > function. Also, original "info" is treated as a special case, now it is > treated as a sub command group, global variable info_cmds is not used > any more. > > Signed-off-by: Wenchao Xia > --- > monitor.c | 12 ++++++------ > 1 files changed, 6 insertions(+), 6 deletions(-) > > diff --git a/monitor.c b/monitor.c > index bc60171..c706644 100644 > --- a/monitor.c > +++ b/monitor.c > @@ -4180,6 +4180,11 @@ static void monitor_find_completion(Monitor *mon, > goto cleanup; > } > > + if (cmd->sub_table) { > + return monitor_find_completion(mon, cmd->sub_table, > + cmdline + strlen(cmd->name)); > + } > + > ptype = next_arg_type(cmd->args_type); > for(i = 0; i < nb_args - 2; i++) { > if (*ptype != '\0') { > @@ -4207,12 +4212,7 @@ static void monitor_find_completion(Monitor *mon, > break; > case 's': > /* XXX: more generic ? */ I think you can drop this comment too. > - if (!strcmp(cmd->name, "info")) { > - readline_set_completion_index(mon->rs, strlen(str)); > - for(cmd = info_cmds; cmd->name != NULL; cmd++) { > - cmd_completion(mon, str, cmd->name); > - } > - } else if (!strcmp(cmd->name, "sendkey")) { > + if (!strcmp(cmd->name, "sendkey")) { > char *sep = strrchr(str, '-'); > if (sep) > str = sep + 1;