* [PATCH] _git: Respect tags for subcommand completion.
@ 2014-12-22 20:45 Daniel Shahaf
2014-12-22 22:04 ` Mikael Magnusson
0 siblings, 1 reply; 4+ messages in thread
From: Daniel Shahaf @ 2014-12-22 20:45 UTC (permalink / raw)
To: zsh-workers
[-- Attachment #1: Type: text/plain, Size: 70 bytes --]
Attached a patch to improve the 'git <TAB>' user experience.
Daniel
[-- Attachment #2: 0001-_git-Respect-tags-for-subcommand-completion.patch --]
[-- Type: text/x-patch, Size: 4677 bytes --]
>From 6c5bc94d11ddf516188fb96f2cf16b15991f8f5f Mon Sep 17 00:00:00 2001
From: Daniel Shahaf <d.s@daniel.shahaf.name>
Date: Tue, 16 Dec 2014 23:43:28 +0000
Subject: [PATCH] _git: Respect tags for subcommand completion.
It is now possible to use the tag-order style to stagger the overwhelming
'git <TAB>' subcommand listing. For example:
zstyle ':completion::complete:git:argument-1:' tag-order \
main-porcelain-commands user-commands third-party-commands \
ancillary-manipulator-commands ancillary-interrogator-commands \
plumbing-manipulator-commands plumbing-interrogator-commands \
aliases
---
Completion/Unix/Command/_git | 68 +++++++++++++++++++++++++++++++++++---------
1 file changed, 54 insertions(+), 14 deletions(-)
diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index 8fcfc15..bdb58e5 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -5206,20 +5206,60 @@ _git_commands () {
integer ret=1
- # TODO: Is this the correct way of doing it? Should we be using _alternative
- # and separate functions for each set of commands instead?
- _describe -t aliases alias unique_aliases && ret=0
- _describe -t main-porcelain-commands 'main porcelain command' main_porcelain_commands && ret=0
- _describe -t user-commands 'user command' user_commands && ret=0
- _describe -t third-party-commands 'third-party command' third_party_commands && ret=0
- _describe -t ancillary-manipulator-commands 'ancillary manipulator command' ancillary_manipulator_commands && ret=0
- _describe -t ancillary-interrogator-commands 'ancillary interrogator command' ancillary_interrogator_commands && ret=0
- _describe -t interaction-commands 'interaction command' interaction_commands && ret=0
- _describe -t plumbing-manipulator-commands 'plumbing manipulator command' plumbing_manipulator_commands && ret=0
- _describe -t plumbing-interrogator-commands 'plumbing interrogator command' plumbing_interrogator_commands && ret=0
- _describe -t plumbing-sync-commands 'plumbing sync command' plumbing_sync_commands && ret=0
- _describe -t plumbing-sync-helper-commands 'plumbing sync helper command' plumbing_sync_helper_commands && ret=0
- _describe -t plumbing-internal-helper-commands 'plumbing internal helper command' plumbing_internal_helper_commands && ret=0
+ _tags \
+ aliases \
+ main-porcelain-commands \
+ user-commands \
+ third-party-commands \
+ ancillary-manipulator-commands \
+ ancillary-interrogator-commands \
+ interaction-commands \
+ plumbing-manipulator-commands \
+ plumbing-interrogator-commands \
+ plumbing-sync-commands \
+ plumbing-sync-helper-commands \
+ plumbing-internal-helper-commands
+
+ while _tags; do
+
+ _requested aliases && \
+ _describe -t aliases 'alias' unique_aliases && ret=0
+
+ _requested main-porcelain-commands && \
+ _describe -t main-porcelain-commands 'main porcelain command' main_porcelain_commands && ret=0
+
+ _requested user-commands && \
+ _describe -t user-commands 'user command' user_commands && ret=0
+
+ _requested third-party-commands && \
+ _describe -t third-party-commands 'third-party command' third_party_commands && ret=0
+
+ _requested ancillary-manipulator-commands && \
+ _describe -t ancillary-manipulator-commands 'ancillary manipulator command' ancillary_manipulator_commands && ret=0
+
+ _requested ancillary-interrogator-commands && \
+ _describe -t ancillary-interrogator-commands 'ancillary interrogator command' ancillary_interrogator_commands && ret=0
+
+ _requested interaction-commands && \
+ _describe -t interaction-commands 'interaction command' interaction_commands && ret=0
+
+ _requested plumbing-manipulator-commands && \
+ _describe -t plumbing-manipulator-commands 'plumbing manipulator command' plumbing_manipulator_commands && ret=0
+
+ _requested plumbing-interrogator-commands && \
+ _describe -t plumbing-interrogator-commands 'plumbing interrogator command' plumbing_interrogator_commands && ret=0
+
+ _requested plumbing-sync-commands && \
+ _describe -t plumbing-sync-commands 'plumbing sync command' plumbing_sync_commands && ret=0
+
+ _requested plumbing-sync-helper-commands && \
+ _describe -t plumbing-sync-helper-commands 'plumbing sync helper command' plumbing_sync_helper_commands && ret=0
+
+ _requested plumbing-internal-helper-commands && \
+ _describe -t plumbing-internal-helper-commands 'plumbing internal helper command' plumbing_internal_helper_commands && ret=0
+
+ (( ret )) || break
+ done
return ret
}
--
1.9.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] _git: Respect tags for subcommand completion.
2014-12-22 20:45 [PATCH] _git: Respect tags for subcommand completion Daniel Shahaf
@ 2014-12-22 22:04 ` Mikael Magnusson
2014-12-23 0:27 ` Oliver Kiddle
0 siblings, 1 reply; 4+ messages in thread
From: Mikael Magnusson @ 2014-12-22 22:04 UTC (permalink / raw)
To: Daniel Shahaf; +Cc: zsh workers
On Mon, Dec 22, 2014 at 9:45 PM, Daniel Shahaf <d.s@daniel.shahaf.name> wrote:
> Attached a patch to improve the 'git <TAB>' user experience.
>
> Daniel
Could you write a few words about what the patch actually does? Eg,
what's wrong with the current status quo?
% git <tab>
---- alias
amend -- alias for 'commit --amend'
...
---- main porcelain command
add -- add file contents to index
am -- apply patches from a mailbox
...
---- ancillary manipulator command
config -- get and set repository or global options
fast-export -- data exporter
...
---- ancillary interrogator command
blame -- show what revision and author last modified each
line of a file
cherry -- find commits not merged upstream
... etc
--
Mikael Magnusson
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] _git: Respect tags for subcommand completion.
2014-12-22 22:04 ` Mikael Magnusson
@ 2014-12-23 0:27 ` Oliver Kiddle
2014-12-23 1:33 ` Mikael Magnusson
0 siblings, 1 reply; 4+ messages in thread
From: Oliver Kiddle @ 2014-12-23 0:27 UTC (permalink / raw)
To: zsh workers
Mikael Magnusson wrote:
> > Attached a patch to improve the 'git <TAB>' user experience.
>
> Could you write a few words about what the patch actually does? Eg,
> what's wrong with the current status quo?
Did you perhaps not notice the subsequent text in the lead up to the
patch?
The current code is not using a single tag loop for all of the different
types of commands. The default behaviour won't change much but with
the tag-order style, you will be able to reorder the commands or have
certain types only completed if others don't match or if _next_tags is
invoked.
Oliver
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] _git: Respect tags for subcommand completion.
2014-12-23 0:27 ` Oliver Kiddle
@ 2014-12-23 1:33 ` Mikael Magnusson
0 siblings, 0 replies; 4+ messages in thread
From: Mikael Magnusson @ 2014-12-23 1:33 UTC (permalink / raw)
To: Oliver Kiddle; +Cc: zsh workers
On Tue, Dec 23, 2014 at 1:27 AM, Oliver Kiddle <okiddle@yahoo.co.uk> wrote:
> Mikael Magnusson wrote:
>> > Attached a patch to improve the 'git <TAB>' user experience.
>>
>> Could you write a few words about what the patch actually does? Eg,
>> what's wrong with the current status quo?
>
> Did you perhaps not notice the subsequent text in the lead up to the
> patch?
>
> The current code is not using a single tag loop for all of the different
> types of commands. The default behaviour won't change much but with
> the tag-order style, you will be able to reorder the commands or have
> certain types only completed if others don't match or if _next_tags is
> invoked.
I did see it, but I didn't understand what difference it would make
since I already successfully use tag-order with _git. I see now though
that it only works because I hide some tags, I don't reorder anything.
(eg, with the - '! plumbing-blabla' syntax).
--
Mikael Magnusson
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-12-23 1:33 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-22 20:45 [PATCH] _git: Respect tags for subcommand completion Daniel Shahaf
2014-12-22 22:04 ` Mikael Magnusson
2014-12-23 0:27 ` Oliver Kiddle
2014-12-23 1:33 ` Mikael Magnusson
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).