diff options
Diffstat (limited to 'Completion/Unix/Command/_ri')
-rw-r--r-- | Completion/Unix/Command/_ri | 46 |
1 files changed, 22 insertions, 24 deletions
diff --git a/Completion/Unix/Command/_ri b/Completion/Unix/Command/_ri index 4d5a72985..fe458e25f 100644 --- a/Completion/Unix/Command/_ri +++ b/Completion/Unix/Command/_ri @@ -26,33 +26,22 @@ _arguments -C \ '*:ri name:->ri-name' && return if [[ "$state" = ri-name ]]; then - local -a ri_dirs ri_ext ri_names ri_wants ri_names + local -a ri_dirs ri_names ri_wants ri_names local class_dir esc_name dir curtag tag descr expl - if "ruby${words[1]#ri}" -rrdoc/ri/ri_options -e 1 >/dev/null 2>&1; then - # Old-style Ruby 1.8.x RI - ri_dirs=( ${(f)"$(_call_program ri-names "ruby${words[1]#ri}" -rrdoc/ri/ri_options -e '"o = RI::Options.instance; o.parse(ARGV); o.path.each { |p| puts p }"' -- ${(kv)opt_args[(I)-d|--doc-dir|--(system|site|gems|home)]})"} ) - ri_ext=yaml - elif "ruby${words[1]#ri}" -rrdoc/ri -rrdoc/ri/store -e 1 >/dev/null 2>&1; then - # Newer-style Ruby 1.9.2 RI - ri_dirs=( ${(f)"$(_call_program ri-names "$words[1]" ${(kv)opt_args[(I)-d|--doc-dir|--((no-|)(system|site|gems|home)|standard-docs)]} --list-doc-dirs -f bs -T)"} ) - ri_ext=ri - else - # New-style Ruby 1.9+ RI - ri_dirs=( ${(f)"$(_call_program ri-names "$words[1]" ${(kv)opt_args[(I)-d|--doc-dir|--((no-|)(system|site|gems|home)|standard-docs)]} --list-doc-dirs -f plain -T)"} ) - ri_ext=yaml - fi + ri_dirs=( ${(f)"$(_call_program ri-names "$words[1]" ${(kv)opt_args[(I)-d|--doc-dir|--((no-|)(system|site|gems|home)|standard-docs)]} --list-doc-dirs -f bs -T)"} ) - if compset -P '?*(::|\#|.)'; then + if compset -P '?*(::|:|\#|.)'; then class_dir=${IPREFIX//(::|\#|.)/\/} fi esc_name=${${(Q)PREFIX}//(#b)([^A-Za-z0-9_])/$(printf %%%x ${(qq)match[1]})} case "$IPREFIX" in - (*::) ri_wants=( 'classes:class names' 'class-methods:class methods' );; - (*\#) ri_wants=( 'instance-methods:instance methods' );; - (*.) ri_wants=( 'class-methods:class methods' 'instance-methods:instance methods' );; - (*) ri_wants=( 'classes:class names' ) + (*::) ri_wants=( 'classes:class name' 'class-methods:class method' );; + (*:) ri_wants=( 'docs:documentation file' );; + (*\#) ri_wants=( 'instance-methods:instance method' );; + (*.) ri_wants=( 'class-methods:class method' 'instance-methods:instance method' );; + (*) ri_wants=( 'classes:class name' 'gems:gem' ) esac for curtag in $ri_wants; do @@ -63,27 +52,36 @@ if [[ "$state" = ri-name ]]; then while _tags; do while _next_label "$tag" expl "$descr"; do ri_wants=() + suf=() case "$tag" in + (gems) + ri_wants=( ruby ${${(f)"$(_call_program gems gem${words[1]#ri} list -q --no-versions)"}%% *} ) + suf=( -S : ) + ;; (classes) for dir in $ri_dirs[@]; do ri_wants+=( $dir/$class_dir*(-/:t) ) done + suf=( -S '::' ) ;; (class-methods) for dir in $ri_dirs[@]; do - fnames=( $dir/$class_dir*-c.$ri_ext(-.:t) ) - ri_wants+=( ${${fnames%-c.$ri_ext}//(#b)%(??)/$(print "\\x$match[1]")} ) + fnames=( $dir/$class_dir*-c.ri(-.:t) ) + ri_wants+=( ${${fnames%-c.ri}//(#b)%(??)/$(print "\\x$match[1]")} ) done ;; (instance-methods) for dir in $ri_dirs[@]; do - fnames=( $dir/$class_dir*-i.$ri_ext(-.:t) ) - ri_wants+=( ${${fnames%-i.$ri_ext}//(#b)%(??)/$(print "\\x$match[1]")} ) + fnames=( $dir/$class_dir*-i.ri(-.:t) ) + ri_wants+=( ${${fnames%-i.ri}//(#b)%(??)/$(print "\\x$match[1]")} ) done ;; + (docs) + ri_wants=( ${${(f)"$(_call_program docs $words[1] ${(kv)opt_args[(I)-d|--doc-dir|--((no-|)(system|site|gems|home)|standard-docs)]} $IPREFIX)"}:#=*} ) + ;; esac ri_names=( ${(Q)ri_wants} ) - compadd -S '' -d ri_names -a "$expl[@]" ri_wants && ret=0 + compadd $suf -d ri_names -a "$expl[@]" ri_wants && ret=0 done (( ret )) || break done |