From: Peter Stephenson <p.stephenson@samsung.com>
To: Zsh Hackers' List <zsh-workers@zsh.org>
Subject: PATCH: (maybe) negative ranges
Date: Wed, 30 Sep 2015 17:51:24 +0100 [thread overview]
Message-ID: <20150930175124.00560d22@pwslap01u.europe.root.pri> (raw)
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
next reply other threads:[~2015-09-30 17:01 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-30 16:51 Peter Stephenson [this message]
2015-09-30 17:26 ` Mikael Magnusson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150930175124.00560d22@pwslap01u.europe.root.pri \
--to=p.stephenson@samsung.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).