On Mon, Jul 07, 2008 at 01:09:06PM +1000, Trent W. Buck wrote:
> The upstream maintainers of a package I maintain (darcs) provide both
> bash and zsh completion snippets. Currently I install the latter to
> /etc/bash_completion.d/darcs, but according to Clint of #debian-devel,
> the only way to get these snippets activated by default is to push
> them to zsh's upstream CVS.
Well, no, technically we can also make them patches downstream in the
zsh package, but what would be the point of forking?
> It would be a good idea if individual maintainers could extend zsh's
> completion by just dropping a snippet in some directory analogous to
> bash's /etc/bash_completion.d.
One benefit to doing it centrally is that any API changes can be
fixed with a single changeset. What benefits does a completion.d
directory offer?
> PS: zsh already has a /usr/share/zsh/functions/Completion/Unix/_darcs,
> which may or may not invalidate my specific case.
Excluding comments, here is a diff between the zsh version and the darcs
source package version. To me the zsh version looks a bit more robust
and handles URL arguments to darcs changes --repo.
If anything needs an update in the zsh version, let us know.
--- /proc/self/fd/11 2008-07-12 09:24:30.561214788 -0400
+++ /proc/self/fd/19 2008-07-12 09:24:30.561214788 -0400
@@ -1,4 +1,6 @@
+
+
setopt EXTENDED_GLOB
local DARCS=$words[1]
@@ -63,8 +65,6 @@
action[i]='_users' ;;
EMAIL|FROM)
action[i]='_email_addresses' ;;
- URL)
- action[i]='_darcs_repository_or_tree' ;;
*)
action[i]='' ;;
esac
@@ -98,8 +98,9 @@
_call_program help-commands darcs --help | while read -A hline; do
(( ${#hline} < 2 )) && continue
[[ $hline[1] == darcs ]] && continue
- [[ $hline[1] == [A-Z]* ]] && continue
- cmdlist=( $cmdlist
"${hline[1]}:${hline[2,-1]/(#b)([A-Z])(*)./${match[1]:l}$match[2]}" )
+ [[ $hline[1] == Usage: ]] && continue
+ [[ $hline[1] == Use ]] && continue
+ cmdlist=( $cmdlist "${hline[1]}:${hline[2,-1]}" )
done
arguments=(':commands:(($cmdlist))')
fi
@@ -189,7 +190,12 @@
local in_tree_head in_tree_tail
_darcs_make_tree_path in_tree_head in_tree_tail
- local recorded_dir="$abs_root/_darcs/current/$in_tree_head"
+ local recorded_dir
+ if [[ -d $abs_root/_darcs/current ]]; then
+ recorded_dir="$abs_root/_darcs/current/$in_tree_head"
+ else
+ recorded_dir="$abs_root/_darcs/pristine/$in_tree_head"
+ fi
local -a controlled_files controlled_dirs existing_files existing_dirs
local -a dir_display_strs removed_dir_display_strs
controlled_files=${(z)$(print $recorded_dir/$in_tree_tail*(.:t))}
@@ -235,8 +241,11 @@
local local_repos_path="$(_darcs_absolute_tree_root)/_darcs/prefs/repos"
local global_repos_path="$HOME/.darcs/repos"
local -a local_repos global_repos
- [[ -e $local_repos_path ]] && local_repos=( $(<$local_repos_path) )
- [[ -e $global_repos_path ]] && global_repos=( $(<$global_repos_path) )
+ local -a global_repos
+ [[ -e $local_repos_path ]] && cat $local_repos_path | read -A local_repos
+ [[ -e $global_repos_path ]] && cat $global_repos_path | read -A
global_repos
+ local_repos=${local_repos:# #}
+ global_repos=${global_repos:# #}
_description repositories expl "repositories"
(( ${#local_repos} )) && compadd "[EMAIL PROTECTED]" -- "[EMAIL PROTECTED]"
(( ${#global_repos} )) && compadd "[EMAIL PROTECTED]" -- "[EMAIL PROTECTED]"
@@ -445,6 +454,3 @@
}
_darcs_main "$@"
-
-
-
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]