From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5285 invoked by alias); 31 Oct 2015 20:31:05 -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: 37037 Received: (qmail 28080 invoked from network); 31 Oct 2015 20:31:03 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, MISSING_HEADERS,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1446323082; bh=OXYYWsM4csB/6mV3fpy0wzFgjtC1RTpBDcL6QQXNQNk=; h=From:cc:Subject:In-reply-to:References:Date:From:Subject; b=F/4F/qQWfvnAp2wz3HXt6fo8K9TLiygaD5GiIwt6xL653fDbNMUZwlQ04NSWkHAsgT8rzdyt7EOAMl8kV7ZqOaBcc7cBrFJieBLt703Ozo8cfv/GLCoFN0L4RJe1FXo1+VJlTj6NX4T0aKY/q8O4UdcVk+r8q3O/QY97AwbB8aTStuxUQ/c0txMDOObYRNlPrYQzNnTVr8EV87b3MIGafEDEhvp4q6yJrqxoapojvMwnIJSZOgeMHuorP12dcuhFXC8mVzcop+C+5phUku6R08y8wKDSN31bpOaBIt8ztfaYKgSCrkZbpZ4XSWmbBlW16Cy+SUiVVtZupD9y28OEOg== X-Yahoo-Newman-Id: 725820.61528.bm@smtp105.mail.ir2.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: jxX08zsVM1nEriEbh4RSfroz.RxvfLNOQ1b5r01e7zn9x5E 5t3.5L5eJ4OstqsXZo3Vem1oRwkCgi51y0mQDrKxlniEhPRPGsGNWYLGDIPg .FqyQ3qCvtyBSnTk07UDB5DfXZUeEkRAUUD3TJXK5nnI7gZDeXuRX_iZYSFM TAsy7zs_o8rnuDcfBVyf7OpDktuhngjmj_vtYCmpEldOQmtnapvNHPc7oJi1 KafnYoCcnZMRv_Y_KSmfdVfti.DGJdeMlNOGhI6EV5hc8uIp_1VoFrnJDlWs thPVkmLHwuVl1C0ZwEBQdnhhJK0PoDgkAFIozqNKDlgjHrsfdlvmUWgUNud_ MJSuLi1mEVEu88glaimQzrcuVYVjbFneFiez5RLKMzpjY.7ROXJPQHNqdwqv lOo8AHs9DCqkMpjNTu.N3TQYC4kkV0jaw46x03tddRifw_QJHKQ.yJk1zNqs 79EC2PJBis2kgkRjJiVwDA1doujvSoix00JNZB4GmerOrgibrLTqKbrPkO1w ASUWnrNhy5ac6yLBZLJcYtJHKeutxxw-- X-Yahoo-SMTP: opAkk_CswBAce_kJ3nIPlH80cJI- From: Oliver Kiddle cc: zsh-workers@zsh.org Subject: Re: __git_recent_commits cannot be called twice Re: [PATCH 2/5] _git: Offer @~$n as completion of recent commits. In-reply-to: <20151031125127.GA2360@tarsus.local2> References: <20151025183458.GK11372@tarsus.local2> <20151031125127.GA2360@tarsus.local2> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <25551.1446323081.1@thecus.kiddle.eu> Date: Sat, 31 Oct 2015 21:24:41 +0100 Message-ID: <25552.1446323081@thecus.kiddle.eu> Daniel Shahaf wrote: > The new output works fine in 'git commit --fixup=', but not in 'git > show '. This is because the latter calls __git_recent_commits via > two distinct codepaths. Here's a minimal example: Calling one function via two codepaths is the basic problem here. We should avoid doing that rather than trying to hack it to work. > 25 HEAD master > 26 @~0 -- [HEAD] m (71 seconds ago) > 27 5d97266 -- [HEAD] m (71 seconds ago) > > This is only a workaround because grouping @~0 and 5d97266 is desirable, > since they both refer to the same commit. Is it really useful to add matches for the abbreviated hashes such as 5d97266? I never type them. Matches for the HEAD form might be more useful. I'd also consider using the prefix-needed style with the @ form and perhaps even with HEAD. It might be better to cope with the problem of more than one commit having the same comment by not using _describe but adding matches manually. > The underlying problematic behaviour is reproducible without _git: > > 1 $ zsh -f > 2 % _f() { local -a x=(foo:aaa bar:aaa); repeat 2 _describe -tt 'desc' x } > 3 % compdef _f f _describe removes the 'rows' token from compstate[list]. So given the following set of matches/descriptions: w x -- 0 y z -- 1 It adds matches in column first order: w y x z 0 1 This means the descriptions are all added last so in this case: compadd -E2 '-- 0' '-- 1' With two separate _describe calls, it is like adding the matches in this order (with setopt nolistrowsfirst): w x 0 y z 1 The description matches are very wide due to space padding so it is no longer able to arrange matches in columns - hence the output you described. Perhaps you could change compdescribe to do things in row first order but it may have other associated problems, particularly when it comes to the algorithm used to pack matches in suitable column widths. _describe was written with the assumption that it is fully responsible for the match group it is adding matches for. It is best to only use it when that is the case. I've been thinking that it could be useful to add a helper like _describe but lacking the feature of grouping matches with a common description. That's the key feature of _describe. _describe is often used when it perhaps shouldn't be because it is also a simple and convenient function when you want descriptions. Any ideas on a name for such a new helper? Oliver