# HG changeset patch # User Brendan Cully # Date 1228370494 28800 # Node ID 05010666fb19c323af31df875a082ecca97a7e0d # Parent 3a829f29d1e262c7e468cd831d63757fd4fc02dd Update zsh completion for new help format diff -r 3a829f29d1e2 -r 05010666fb19 contrib/zsh_completion --- a/contrib/zsh_completion Wed Dec 03 01:28:33 2008 +0100 +++ b/contrib/zsh_completion Wed Dec 03 22:01:34 2008 -0800 @@ -4,14 +4,13 @@ # it into your zsh function path (/usr/share/zsh/site-functions for # instance) # -# Copyright (C) 2005 Steve Borho +# Copyright (C) 2005-6 Steve Borho # Copyright (C) 2006-8 Brendan Cully # # This is free software; you can redistribute it and/or modify it under # the terms of the GNU General Public License as published by the Free # Software Foundation; either version 2 of the License, or (at your # option) any later version. -# emulate -LR zsh setopt extendedglob @@ -117,28 +116,54 @@ _hg_get_commands() { typeset -ga _hg_cmd_list typeset -gA _hg_alias_list - local hline cmd cmdalias - _call_program help hg --verbose help | while read -A hline + local hline cmd cmdalias helpstate + local helpmode=$1 + + _call_program help hg --verbose help $helpmode 2>/dev/null | while read -A hline do - cmd="$hline[1]" - case $cmd in - *:) - cmd=${cmd%:} - _hg_cmd_list+=($cmd) - ;; - *,) - cmd=${cmd%,} - _hg_cmd_list+=($cmd) - integer i=2 - while (( i <= $#hline )) - do - cmdalias=${hline[$i]%(:|,)} - _hg_cmd_list+=($cmdalias) - _hg_alias_list+=($cmdalias $cmd) - (( i++ )) - done - ;; - esac + if [ "$hline" = "list of commands:" ] + then + helpstate="commands" + continue + elif [ "$hline" = "enabled extensions:" ] + then + helpstate="extensions" + continue + elif [ "$hline" = "additional help topics:" ] + then + helpstate="topics" + continue + fi + + if [ "$helpstate" = commands ] + then + cmd="$hline[1]" + case $cmd in + *:) + cmd=${cmd%:} + _hg_cmd_list+=($cmd) + ;; + *,) + cmd=${cmd%,} + _hg_cmd_list+=($cmd) + integer i=2 + while (( i <= $#hline )) + do + cmdalias=${hline[$i]%(:|,)} + _hg_cmd_list+=($cmdalias) + _hg_alias_list+=($cmdalias $cmd) + (( i++ )) + done + ;; + esac + elif [ -z "$helpmode" -a "$helpstate" = extensions ] + then + cmd="$hline[1]" + if [ -n "$cmd" ] + then + _hg_get_commands $cmd + fi + fi done }