summary refs log tree commit diff
diff options
context:
space:
mode:
authorDaniel Shahaf <d.s@daniel.shahaf.name>2014-12-16 23:43:28 +0000
committerDaniel Shahaf <d.s@daniel.shahaf.name>2015-01-05 15:57:42 +0000
commitc7850ac4f64239897b7311c6245785559e2b48e9 (patch)
tree63f45ffdab92774a5982e2083ec9f32a84ae38a5
parent6425db14a49d7faed99ebf22d551ab81aab7e359 (diff)
downloadzsh-c7850ac4f64239897b7311c6245785559e2b48e9.tar.gz
zsh-c7850ac4f64239897b7311c6245785559e2b48e9.tar.xz
zsh-c7850ac4f64239897b7311c6245785559e2b48e9.zip
34042: _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
-rw-r--r--ChangeLog5
-rw-r--r--Completion/Unix/Command/_git68
2 files changed, 59 insertions, 14 deletions
diff --git a/ChangeLog b/ChangeLog
index 601c2e160..75a16bcf7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-01-05  Daniel Shahaf <d.s@daniel.shahaf.name>
+
+	* 34042: Completion/Unix/Command/_git: Respect tags for subcommand
+	completion.
+
 2015-01-05  Peter Stephenson  <p.stephenson@samsung.com>
 
 	* Timofey Titovets: 34053: Completion/Linux/Command/_modutils:
diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index 8fcfc153d..bdb58e52c 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
 }