Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: (maybe) negative ranges
- X-seq: zsh-workers 36722
- From: Peter Stephenson <p.stephenson@xxxxxxxxxxx>
- To: Zsh Hackers' List <zsh-workers@xxxxxxx>
- Subject: PATCH: (maybe) negative ranges
- Date: Wed, 30 Sep 2015 17:51:24 +0100
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- Organization: Samsung Cambridge Solution Centre
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<TAB>
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author