From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29855 invoked by alias); 7 Apr 2013 19:28:53 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 31234 Received: (qmail 4738 invoked from network); 7 Apr 2013 19:28:41 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at closedmail.com does not designate permitted sender hosts) From: Bart Schaefer Message-id: <130407122837.ZM622@torch.brasslantern.com> Date: Sun, 07 Apr 2013 12:28:37 -0700 X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-workers@zsh.org Subject: PATCH: error handling in _complete_help MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Something I had sitting around that seemed like a good test for "git push". This uses an "always" block instead of "trap" to clean up various function overrides in _complete_help, because some errors would cause _complete_help to exit without running the traps, leaving completion broken. Most of the change is indentation. diff --git a/Completion/Base/Widget/_complete_help b/Completion/Base/Widget/_complete_help index 99f2f2d..949a496 100644 --- a/Completion/Base/Widget/_complete_help +++ b/Completion/Base/Widget/_complete_help @@ -6,41 +6,41 @@ _complete_help() { local _sort_tags=_help_sort_tags text i j k tmp typeset -A help_funcs help_tags help_sfuncs help_styles - compadd() { return 1 } - zstyle() { - local _f="${${(@)${(@)funcstack[2,(i)_(main_complete|complete|approximate|normal)]}:#_(dispatch|wanted|requested|all_labels|next_label)}% *}" - - [[ -z "$_f" ]] && _f="${${(@)funcstack[2,(i)_(main_complete|complete|approximate|normal)]}:#_(dispatch|wanted|requested|all_labels|next_label)}" - - if [[ "$help_sfuncs[$2]" != *${_f}* || - "$help_styles[${2}${_f}]" != *${3}* ]]; then - - [[ "$help_sfuncs[$2]" != *${_f}* ]] && help_sfuncs[$2]+=$'\0'"${_f}" - local _t - - case "$1" in - -s) _t='[string] ';; - -a) _t='[array] ';; - -h) _t='[assoc] ';; - *) _t='[boolean]';; - esac - help_styles[${2}${_f}]+=",${_t} ${3}:${_f}" - fi - - # No need to call the completers more than once with different match specs. - - if [[ "$3" = matcher-list ]]; then - set -A "$4" '' - else - builtin zstyle "$@" - fi + { + compadd() { return 1 } + zstyle() { + local _f="${${(@)${(@)funcstack[2,(i)_(main_complete|complete|approximate|normal)]}:#_(dispatch|wanted|requested|all_labels|next_label)}% *}" + + [[ -z "$_f" ]] && _f="${${(@)funcstack[2,(i)_(main_complete|complete|approximate|normal)]}:#_(dispatch|wanted|requested|all_labels|next_label)}" + + if [[ "$help_sfuncs[$2]" != *${_f}* || + "$help_styles[${2}${_f}]" != *${3}* ]]; then + + [[ "$help_sfuncs[$2]" != *${_f}* ]] && help_sfuncs[$2]+=$'\0'"${_f}" + local _t + + case "$1" in + -s) _t='[string] ';; + -a) _t='[array] ';; + -h) _t='[assoc] ';; + *) _t='[boolean]';; + esac + help_styles[${2}${_f}]+=",${_t} ${3}:${_f}" + fi + + # No need to call the completers more than once with different match specs. + + if [[ "$3" = matcher-list ]]; then + set -A "$4" '' + else + builtin zstyle "$@" + fi + } + + ${1:-_main_complete} + } always { + unfunction compadd zstyle } - trap 'unfunction compadd zstyle' EXIT INT - - ${1:-_main_complete} - - unfunction compadd zstyle - trap - EXIT INT for i in "${(@ok)help_funcs}"; do text+=$'\n'"tags in context :completion:${i}:"