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

Problem writing ri completion function



Hi,

I was writing a new completion for ri, the ruby documentation viewing
tool, when I came upon a small problem: ri takes as argument the full
name of a class, module or method.

It can generate a list of all documented functions, which I use to fill
the completion list. This list is very long, so I tried to use
_multi_parts to get a better overview. The problem is: ri uses
different separators to differentiate between class method and instance
methods. For example I have these alternatives:

File (class or module)
File::basename (class method)
File.path (instance method)
File::Stat (another class)
File::Stat::new (another class method)

I currently only use _multi_parts with "." as separator - I don't know
enough zsh scripting to build something to use multiple separators. Any
ideas?

Greetings Tobi

-- 
GPG-Key 0xE2BEA341 - signed/encrypted mail preferred
My, oh so small, homepage: http://portfolio16.de/
http://www.fli4l.de/ - ISDN- & DSL-Router on one disk!
Registered FLI4L-User #00000003
#compdef ri
#
# zsh completion for the ri ruby documentation tool
# from http://www.ruby-talk.org/cgi-bin/scat.rb/ruby/ruby-talk/128677
# + some changes

_ri () {
  _arguments -C -s \
    '(-h --help)'{-h,--help}'[print help message]' \
    '(-c --classes)'{-c,--classes}'[Display the names of classes and modules we know about]' \
    '(-d --doc-dir)'{-d+,--doc-dir+}'[A directory to search for documentation]:directory:_files -/' \
    '(-f --format)'{-f,--format}'[Format to use when displaying output]:format:(ansi bs html plain simple)' \
    '(-l --list-names)'{-l,--list-names}'[List all the names known to RDoc, one per line]' \
    '(-T --no-pager)'{-T,--no-pager}'[Send output directly to stdout]' \
    '(-w --width)'{-w+,--width+}'[output width]:width: ' \
    '(-v --version)'{-v,--version}'[Display the version of ri]' \
    "*:help topics:_ri_names"
}

_ri_names () {
  if ( [[ ${+_ri_list_names} -eq 0 ]] || _cache_invalid ri_names ) &&
    ! _retrieve_cache ri_names; then
    _ri_list_names=( ${$(_call_program ri--list-names RI= ri -l -T 2>/dev/null)//\#/.} )
    _store_cache ri_names _ri_list_names
  fi
  _multi_parts -i "." _ri_list_names
}

_ri "$@"

Attachment: signature.asc
Description: Digital signature



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