2 ### vim:ft=zsh:foldmethod=marker
3 ## Copyright: 2009, Frank Terbeck <ft@bewatermyfriend.org>
5 function _lookup_aliases() {
10 for al in ${(k)LOOKUP_aliases}; do
11 aliases+=("${al}:alias for ${LOOKUP_aliases[$al]}")
14 _describe -t aliases 'backend alias' aliases
17 function _lookup_backends() {
21 local -x lookup_describe
24 if [[ -z ${lookup_nohide} ]] &&
25 zstyle -t ":completion:${curcontext}" hide-aliased-backends ; then
32 for be in ${LOOKUP_backends}; do
33 (( hidealiased > 0 )) && [[ -n ${(Mv)LOOKUP_aliases:#$be} ]] && continue
34 backends+=("${be}:$(LOOKUP_be_${be})")
37 _describe -t backends 'backend' backends
40 function _lookup_backends_nohide() {
41 local -x lookup_nohide='yes'
45 function _lookup_backends_and_aliases() {
47 'aliases: :_lookup_aliases' \
48 'commands: :_lookup_backends'
52 local context curcontext state line ret
55 local -ix lookup_complete
59 '-a[add a backend alias]:alias definition:'
60 '-d[remove backand alias]:alias name:_lookup_aliases'
61 '-h[provide help]:lookup backend:_lookup_backends_nohide'
62 '-i[(re)initialize lookup]:'
63 '-l[list available backends]:'
64 '-L[list defined backend aliases]:'
65 '-Q[let a handler create the QUERY string]'
66 '-q[let a handler create the QUERY string, with arg]:argument for query handler:'
67 '-P[print which browser command would be used]'
68 '-R[send url to remote browser]'
69 '*:: :->be_or_options'
71 _arguments -C -s -w ${args} && return
73 if [[ ${state} == "be_or_options" ]]; then
74 if (( CURRENT == 1 )) ; then
75 _lookup_backends_and_aliases
78 if [[ -n ${LOOKUP_aliases[$backend]} ]] ; then
79 aw=( ${(z)${LOOKUP_aliases[$backend]}} )
80 (( CURRENT = CURRENT + ${#aw} - 1 ))
85 curcontext="${curcontext%:*:*}:lookup-${backend}:"
86 _call_function ret LOOKUP_be_${backend}