All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luiz Capitulino <lcapitulino@redhat.com>
To: Hani Benhabiles <kroosec@gmail.com>
Cc: qemu-devel@nongnu.org, stefanha@redhat.com
Subject: Re: [Qemu-devel] [PATCH 2/7] monitor: Convert help|? to use command_completion.
Date: Mon, 5 May 2014 15:51:37 -0400	[thread overview]
Message-ID: <20140505155137.0889bd32@redhat.com> (raw)
In-Reply-To: <1398614409-30792-3-git-send-email-kroosec@gmail.com>

On Sun, 27 Apr 2014 17:00:03 +0100
Hani Benhabiles <kroosec@gmail.com> wrote:

> Signed-off-by: Hani Benhabiles <hani@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().

       reply	other threads:[~2014-05-05 19:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1398614409-30792-1-git-send-email-kroosec@gmail.com>
     [not found] ` <1398614409-30792-3-git-send-email-kroosec@gmail.com>
2014-05-05 19:51   ` Luiz Capitulino [this message]
2014-05-07 21:42     ` [Qemu-devel] [PATCH 2/7] monitor: Convert help|? to use command_completion Hani Benhabiles
2014-05-05 19:54 ` [Qemu-devel] [PATCH 0/7] Miscellaneous command completion patches Luiz Capitulino
     [not found] ` <1398614409-30792-6-git-send-email-kroosec@gmail.com>
2014-05-07  9:18   ` [Qemu-devel] [PATCH 5/7] monitor: Add set_link arguments completion Stefan Hajnoczi
     [not found] ` <1398614409-30792-7-git-send-email-kroosec@gmail.com>
2014-05-07  9:21   ` [Qemu-devel] [PATCH 6/7] monitor: Add netdev_add type argument completion Stefan Hajnoczi
     [not found] ` <1398614409-30792-8-git-send-email-kroosec@gmail.com>
2014-05-07  9:22   ` [Qemu-devel] [PATCH 7/7] monitor: Add netdev_del id " Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140505155137.0889bd32@redhat.com \
    --to=lcapitulino@redhat.com \
    --cc=kroosec@gmail.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.