diff --git a/contrib/ri b/contrib/ri index ad127e02..7066d497 100644 --- a/contrib/ri +++ b/contrib/ri @@ -1,12 +1,12 @@ # ri completion for Ruby documentation by Ian Macdonald # -# $Id: ri,v 1.1 2002/04/22 07:47:13 ianmacd Exp $ +# $Id: ri,v 1.2 2003/09/17 07:39:21 ianmacd Exp $ # ri_get_methods() { COMPREPLY=( "$( ri ${classes[@]} | ruby -ane 'if /^-/.../^-/ and \ ! /^-/ and ! /^ +(class|module): / then \ - print $_.strip.split(", ").grep(/^[^[]*$/).join("\n"); \ + print $_.strip.split(/, /).grep(/^[^\[]*$/).join("\n"); \ end' | sort -u )" ) COMPREPLY=( $( compgen $prefix -W '${COMPREPLY[@]}' -- $method ) ) } @@ -30,8 +30,14 @@ _ri() return 0 fi - classes=( $( ri | ruby -ne 'if /^I have/..$stdin.eof then \ - if /^ .*[A-Z]/ then print; end; end' ) ) + if [ "$( ri -v 2>&1 )" = "ri 1.8a" ]; then + classes=( $( ri | ruby -ne 'if /^'"'"'ri'"'"' has/..$stdin.eof then \ + if /^ .*[A-Z]/ then print; end; end' )) + else + classes=( $( ri | ruby -ne 'if /^I have/..$stdin.eof then \ + if /^ .*[A-Z]/ then print; end; end' )) + fi + if [[ "$cur" == [A-Z]* ]]; then # we're completing on class COMPREPLY=( $( compgen -W '${classes[@]}' -- $cur ) )