From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11108 invoked by alias); 30 Sep 2015 17:01:40 -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: 36722 Received: (qmail 23256 invoked from network); 30 Sep 2015 17:01:39 -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=-1.9 required=5.0 tests=BAYES_00,T_HDRS_LCASE, T_MANY_HDRS_LCASE autolearn=ham autolearn_force=no version=3.4.0 X-AuditID: cbfec7f5-f794b6d000001495-0b-560c1315654f Date: Wed, 30 Sep 2015 17:51:24 +0100 From: Peter Stephenson To: Zsh Hackers' List Subject: PATCH: (maybe) negative ranges Message-id: <20150930175124.00560d22@pwslap01u.europe.root.pri> Organization: Samsung Cambridge Solution Centre X-Mailer: Claws Mail 3.7.9 (GTK+ 2.22.0; i386-redhat-linux-gnu) MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrJLMWRmVeSWpSXmKPExsVy+t/xK7qiwjxhBov3cFgcbH7I5MDoserg B6YAxigum5TUnMyy1CJ9uwSujBMTnzIXHOSpePvyP0sD4xbOLkZODgkBE4kJZ+ezQthiEhfu rWfrYuTiEBJYyihxc+c9JghnBpPEnFc32UGqhAS2MUo0fuXuYuTgYBFQlZi4KQokzCZgKDF1 02xGkLCIgLZE+0cxkLCwgLpE292dLCA2r4C9RO/Pj2A2v4C+xNW/n5gg9tpLzLxyhhGiRlDi x+R7YDXMAloSm7c1sULY8hKb17xlhrhAXeLG3d3sExgFZiFpmYWkZRaSlgWMzKsYRVNLkwuK k9JzjfSKE3OLS/PS9ZLzczcxQgLw6w7GpcesDjEKcDAq8fC+EOAOE2JNLCuuzD3EKMHBrCTC u4ifJ0yINyWxsiq1KD++qDQntfgQozQHi5I478xd70OEBNITS1KzU1MLUotgskwcnFINjBcS Ch7cFundM//LphnlRpxWCxfw1GwOr8i6p3xxosI+Zzfn4vX7pijd8W89MP8228tpJoczvSeK MLHWC5ycmfW/Ypvh4cNpLwv/L30943yafty+ttyK1qrfsfZxC67Xyu45obHvYsw920YOj902 HRqJu/W3pad3fjm8PeRO4LMZBaL7F54+0qbEUpyRaKjFXFScCAAGb/yfPAIAAA== I'd like to be able to ignore ^ at the start of a git range specification to support things like git log r1 ^r2 (which is useful as it saves me having to remember what .. and ... mean and getting infuriated because they mean the opposite for git diff). This being zsh, it's not as easy as it should be. With extendedglob I need to quote the ^ on the command line, which I'm doing with a backslash: git log r1 \^r In the completion function that gets executed as a result it looks like $PREFIX still contains the backslash, so I have to deal with quoting myself and still leave a valid revision to complete in further procesing. This seems to do what I want, but I may have missed up to N! tricks... I have no idea how to tweak this to turn '^stuff into the equivalent of having 'stuff in the bowels and '^stuff still on the command line, which looks like the only way of consistently keeping the quotes and still have the completion work. pws diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git index 40a9fb6..1fcde90 100644 --- a/Completion/Unix/Command/_git +++ b/Completion/Unix/Command/_git @@ -5753,7 +5753,14 @@ __git_commit_ranges () { if compset -P '*..(.|)'; then expl=( $* ) else - compset -S '..*' || suf=( -S .. -r '.@~ ^:\t\n\-' ) + if ! compset -S '..*'; then + local match mbegin mend + if [[ ${PREFIX} = (#b)((\\|)\^)* ]]; then + compset -p ${#match[1]} + else + suf=( -S .. -r '.@~ ^:\t\n\-' ) + fi + fi expl=( $* $suf ) fi