From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2105 invoked from network); 1 Sep 2008 18:07:21 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.5 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 1 Sep 2008 18:07:21 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 56848 invoked from network); 1 Sep 2008 18:07:14 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 1 Sep 2008 18:07:14 -0000 Received: (qmail 22977 invoked by alias); 1 Sep 2008 18:07:02 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 25583 Received: (qmail 22950 invoked from network); 1 Sep 2008 18:07:00 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 1 Sep 2008 18:07:00 -0000 Received: from mta-2.ms.rz.rwth-aachen.de (mta-2.ms.rz.RWTH-Aachen.DE [134.130.7.73]) by bifrost.dotsrc.org (Postfix) with ESMTPS id 7D741801E2B4 for ; Mon, 1 Sep 2008 20:06:55 +0200 (CEST) Received: from ironport-out-1.rz.rwth-aachen.de ([134.130.3.58]) by mta-2.ms.rz.RWTH-Aachen.de (Sun Java System Messaging Server 6.2-8.04 (built Feb 28 2007)) with ESMTP id <0K6J007TW3NJEFE0@mta-2.ms.rz.RWTH-Aachen.de> for zsh-workers@sunsite.dk; Mon, 01 Sep 2008 20:06:55 +0200 (CEST) Received: from relay.rwth-aachen.de ([134.130.3.1]) by ironport-in-1.rz.rwth-aachen.de with ESMTP; Mon, 01 Sep 2008 20:06:55 +0200 Received: from fsst.voodoo.lan ([212.117.84.168]) by relay.rwth-aachen.de (8.13.7/8.13.3/1) with ESMTP id m81I6s3B017226 for ; Mon, 01 Sep 2008 20:06:54 +0200 (MEST) Received: from hawk by fsst.voodoo.lan with local (Exim 4.69) (envelope-from ) id 1KaDnW-0000Rs-Rt for zsh-workers@sunsite.dk; Mon, 01 Sep 2008 20:06:42 +0200 Date: Mon, 01 Sep 2008 20:06:42 +0200 From: Frank Terbeck Subject: PATCH: partly rewriting alias handling in _git To: zsh workers Mail-followup-to: zsh workers Message-id: <20080901180642.GE6330@fsst.voodoo.lan> MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7BIT Content-disposition: inline X-IronPort-AV: E=Sophos;i="4.32,309,1217800800"; d="scan'208";a="81500472" User-Agent: Mutt/1.5.18 (2008-05-17) X-Virus-Scanned: ClamAV 0.92.1/8131/Mon Sep 1 15:33:22 2008 on bifrost X-Virus-Status: Clean While the last patch (zw25561) in that field did improve the handling of git aliases, it also drew my attention to other problems in the code. I've been playing with this version for some time and AFAICS it handles most cases quite well (a lot better than the old one). Another thing, I didn't address in this patch is this: % git c --some args ^- place the cursor here and hit . That does not return completions like 'commit'. If, later in the code (at the end before the last 'case'), you replace "'*::options:->options' && ret=0" with "'*:options:->options' && ret=0", it starts to work. I'm not sure if I am missing something and the two-colon form was used on purpose. Anyway, as for git alias handling: Index: Completion/Unix/Command/_git =================================================================== RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_git,v retrieving revision 1.95 diff -u -r1.95 _git --- Completion/Unix/Command/_git 31 Aug 2008 16:09:08 -0000 1.95 +++ Completion/Unix/Command/_git 1 Sep 2008 18:02:55 -0000 @@ -4285,16 +4285,16 @@ IFS=$oifs ; unset oifs if (( CURRENT >= 3 )) && [[ -n ${git_aliases[$words[2]]} ]] ; then - local -a tmpwords - tmpwords=(${words[1]} ${(z)git_aliases[$words[2]]}) - if [[ -z "${words[3,-1]}" ]] ; then - tmpwords[$(( ${#tmpwords} + 1 ))]="" - else + local -a tmpwords expalias + expalias=(${(z)git_aliases[$words[2]]}) + tmpwords=(${words[1]} ${expalias}) + if [[ -n "${words[3,-1]}" ]] ; then tmpwords+=(${words[3,-1]}) fi + tmpwords+=('') + (( CURRENT += ${#expalias} - 1 )) words=("${tmpwords[@]}") - (( CURRENT += ${#${(z)git_aliases[$words[2]]}} - 1 )) - unset tmpwords + unset tmpwords expalias fi if [[ $service == git ]]; then