[PATCH 1 of 1] bash_completion: complete aliases

Matt Mackall mpm at selenic.com
Thu May 12 18:56:05 CDT 2011


On Thu, 2011-05-12 at 00:14 +0200, Yann E. MORIN wrote:
> # HG changeset patch
> # User "Yann E. MORIN" <yann.morin.1998 at anciens.enib.fr>
> # Date 1305149147 -7200
> # Node ID 96a24fd2ae2a47bc200b014a21d157ed609616da
> # Parent  1a791993ce593024f14a0844f39c963f324e5d93
> bash_completion: complete aliases

The right way to do this is with HGPLAINEXCEPT:

http://www.selenic.com/hg/rev/9f97de157aad

Step 1: make it easy to check for exceptions, eg:

 if not ui.plain(): -> if not ui.plain("feature"):

Step 2: teach the alias code to check for an exception
Step 3: teach completion to use it

> Signed-off-by: "Yann E. MORIN" <yann.morin.1998 at anciens.enib.fr>
> 
> diff --git a/contrib/bash_completion b/contrib/bash_completion
> --- a/contrib/bash_completion
> +++ b/contrib/bash_completion
> @@ -61,9 +61,13 @@
>  
>  _hg_commands()
>  {
> -    local commands
> +    local commands aliases
>      commands="$(_hg_cmd debugcomplete "$cur")" || commands=""
> -    COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$commands' -- "$cur"))
> +    aliases="$(hg debugconfig 2>/dev/null               \
> +               |sed -r -e '/^alias\./!d;'               \
> +                       -e 's/^alias\.([^=]+)=.*/\1/;'   \
> +              )" || aliases=""
> +    COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$commands $aliases' -- "$cur"))
>  }
>  
>  _hg_paths()
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel


-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial-devel mailing list