From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3365 invoked by alias); 27 Jul 2011 08:11:07 -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: 29615 Received: (qmail 29431 invoked from network); 27 Jul 2011 08:10:54 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) 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, SPF_HELO_PASS autolearn=ham version=3.3.1 Received-SPF: none (ns1.primenet.com.au: domain at bewatermyfriend.org does not designate permitted sender hosts) From: Frank Terbeck To: Luka Perkov Cc: zsh-workers@zsh.org Subject: Re: PATCH: _quilt: fix push and pop completion In-Reply-To: <20110726225739.GA6008@w500.lan> (Luka Perkov's message of "Wed, 27 Jul 2011 00:57:39 +0200") References: <20110726225739.GA6008@w500.lan> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) Date: Wed, 27 Jul 2011 09:50:19 +0200 Message-ID: <87wrf46u2s.fsf@ft.bewatermyfriend.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Df-Sender: 430444 Luka Perkov wrote: > Patch fixes 'bug' in _quilt completion script when there is not possible > to do push or pop. Also tabs are replaced with spaces because they were > not consistent. This still doesn't quite work for me. When I'm trying push or pop completion in a directory where there are no quilt patches at all, the completion is still echoing back error messages to me. Also, your patch runs `quilt' twice, which is not needed. How about checking for the return value of `quilt' after running the {un,}applied sub-commands? The following seems to work: diff --git a/Completion/Unix/Command/_quilt b/Completion/Unix/Command/_quilt index a2fd799..fd475ed 100644 --- a/Completion/Unix/Command/_quilt +++ b/Completion/Unix/Command/_quilt @@ -1,5 +1,8 @@ #compdef quilt +local -a tmp +local rc + _arguments \ '--trace' \ '--quiltrc:config file:_files' \ @@ -14,17 +17,29 @@ case "$state" in case "$words[1]" in (applied|delete|files|graph|header|next|previous|refresh|unapplied) - _wanted -V 'patches' expl 'patch' compadd ${(f)"$(quilt series)"} - ;; + _wanted -V 'patches' expl 'patch' compadd ${(f)"$(quilt series)"} + ;; (push) - _wanted -V 'unapplied patches' expl 'patch' compadd ${(f)"$(quilt unapplied)"} - ;; + tmp=( ${(f)"$(quilt unapplied 2>&1)"} ) + rc=$? + if (( rc == 0 )); then + _wanted -V 'unapplied patches' expl 'patch' compadd "${tmp[@]}" + else + _message "No unapplied patches" + fi + ;; (pop) - _wanted -V 'applied patches' expl 'patch' compadd ${(f)"$(quilt applied)"} - ;; + tmp=( ${(f)"$(quilt applied 2>&1)"} ) + rc=$? + if (( rc == 0 )); then + _wanted -V 'applied patches' expl 'patch' compadd "${tmp[@]}" + else + _message "No applied patches" + fi + ;; (*) - _files - ;; + _files + ;; esac ;; esac