Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH: (2/3) _git: Pick up addon completions from $fpath



Frank Terbeck wrote:
> +  _describe -t third-party-addons 'third party addon' _git_third_party && ret=0

Actually, just because the completion is there doesn't mean that
completing the thing at "git <tab>" makes sense, because the addon
program may not even be installed on the system in question.

For example, we're already shipping `_git-buildpackage'. But on a system
where `git-buildpackage' is not installed, I wouldn't want it to appear
in suggestions for "git b<tab>".

Here's something on top of the previous patch to take such situations
into account. I'd squash these two, before committing to CVS.

Regards, Frank


diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index 4567460..a1856df 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -4606,7 +4606,12 @@ _git_commands () {
   _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
-  _describe -t third-party-addons 'third party addon' _git_third_party && ret=0
+  local -a addons
+  local a
+  for a in $_git_third_party; do
+      (( ${+commands[git-${a%%:*}]} )) && addons+=( $a )
+  done
+  _describe -t third-party-addons 'third party addon' addons && ret=0
   _describe -t user-specific-commands 'user specific command' user_commands && ret=0
   return ret
 }



Messages sorted by: Reverse Date, Date, Thread, Author