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

java class names completion widget



Hi,

I'd like to mimic IDEA's (one of Java IDEs) classes searching in zsh. It 
allows to find classes specifying only their names with some lower case 
letters ommitted. For instance, "MDCl" will match "org.bar.MyDumbClass".
More strictly, each capital letter means "this letter followed by any number 
of lower-case letters".

I've made a simple function which generates a regexp by such abbreviations:

function makeClassRegexp {
    word=$1
    res=""
    for (( i=1; $i<=${#word}; i++ )) {
        char=$word[$i]
        if [[ $char == *[[:upper:]]* ]] {
            res=${res}"([[:lower:]]*)"
        }
        res=${res}${char}
    }
    echo $res"(.*)\.java$"
}

Now I can easily find classes under the current dir:

fcl() {
    regexp=`makeClassRegexp $1`
    find . -type f | GREPP $regexp
}

(where GREPP is aliased to 'grep -P' or pcregrep on different distros).

kos@kos ~/work/jrs/src $ fcl SHMa
./org/kos/jrs/SoftHashMap.java

Now I want to convert it into a completion widget. What is the easiest way to 
do it?

Thanks

-- 
/KoS
* Walk softly and carry a fully charged PHASER!			      



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