From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8768 invoked by alias); 4 Mar 2015 02:57:35 -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: 34640 Received: (qmail 2000 invoked from network); 4 Mar 2015 02:57:24 -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=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= daniel.shahaf.name; h=x-sasl-enc:date:from:to:cc:subject :message-id:references:mime-version:content-type :content-transfer-encoding:in-reply-to; s=mesmtp; bh=t4UHqgwFOkL Mu9qDpz0BYg4s+5Y=; b=Dh0MA0zWhgqMaV1xovEbcusAr3QhzsjYJ9xxnIuJtNa /5B5U2ZKpINSrOzMvJTVshItdIa38Saoy7SCb+kdoGzk7JFd4JuvMqsprDm6TSCd a4yHUSHrP09NkSqMYG9kG8c6ym6lCzIqcrwabLcgDPpUT5AHS9JLj/sFaGyoozvI = DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=x-sasl-enc:date:from:to:cc:subject :message-id:references:mime-version:content-type :content-transfer-encoding:in-reply-to; s=smtpout; bh=t4UHqgwFOk LMu9qDpz0BYg4s+5Y=; b=lD/mkAR9PhUyy1bB322QhlQ6+UL4Y6pucgKTBeWYvj mqp1zJOyoDtdpjgCbWKwzhoq3B4ItHRhCBplgdOQupYd+CC2aZ2QS4M4ynF50MYt jAOoq6McaPUf3KE9uiDGzhZ+Qps0bptBgE1oTvAX2eq0iJwiM4cIWVyhAu1N3tMC E= X-Sasl-enc: 7blsgfywnkwXwkY9uyF/6I76TKuIZ1F6JXZJwhEvr94S 1425437843 Date: Wed, 4 Mar 2015 02:57:20 +0000 From: Daniel Shahaf To: Daniel Hahler Cc: zsh-workers@zsh.org Subject: Re: Improved completion for git commit objects (__git_commit_objects) Message-ID: <20150304025720.GG2057@tarsus.local2> References: <54F647E2.5020400@thequod.de> <20150304024000.GF2057@tarsus.local2> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20150304024000.GF2057@tarsus.local2> User-Agent: Mutt/1.5.21 (2010-09-15) Daniel Shahaf wrote on Wed, Mar 04, 2015 at 02:40:00 +0000: > Daniel Hahler wrote on Wed, Mar 04, 2015 at 00:46:42 +0100: > > _guard '[[:xdigit:]](#c,40)' 'commit object name' > > + > > + : ${(AA)commits::=${(f)"$(_call_program commits git --no-pager log --oneline -2 --format='%h%n%s')"}} > > + __git_command_successful $pipestatus || return 1 > > + > > + _wanted commits expl 'commit object name' compadd "$@" -k - commits && ret=0 > > } > > > > I do not fully understand how "_guard" is meant to be used - I need to comment/remove it. > > Should this get chained, e.g. with "_wanted", instead? > > What's the desired behaviour? Suppose that ${(k)commits} is [0123abc, > 4567def] and the user types '--fixup=fedbca'. In this case, you'd > still want the second argument to _guard to be displayed, right? > > In this case, I think you should retain _guard in the "the 'commits' tag > is wanted, but none of ${(k)commits} matches the input so far" codepath. > Makes sense? Never mind that — I think you can just remove the _guard call. The function of _guard is to display a message when the current word matches a pattern (sort of conditionalizing the second colon-separated part of an _arguments option definition); _wanted will print that message instead of _guard. That confused me too the first time I encountered that function. Perhaps a clarification: diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo index 5890f17..89cd051 100644 --- a/Doc/Zsh/compsys.yo +++ b/Doc/Zsh/compsys.yo @@ -4278,12 +4278,12 @@ option `tt(-)tt(-help)'. ) findex(_guard) item(tt(_guard) [ var(options) ] var(pattern descr))( -This function is intended to be used in the var(action) for -the specifications passed to tt(_arguments) and similar functions. It -returns immediately with a non-zero return status if -the string to be completed does not match the var(pattern). If the -pattern matches, the var(descr) is displayed; the function then returns -status zero if the word to complete is not empty, non-zero otherwise. +This function displays var(descr) if var(pattern) matches the string to +be completed. It is intended to be used in the var(action) for the +specifications passed to tt(_arguments) and similar functions. + +The return status is zero if the message was displayed and the word to +complete is not empty, and non-zero otherwise. The var(pattern) may be preceded by any of the options understood by tt(compadd) that are passed down from tt(_description), namely tt(-M), Daniel