Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
java class names completion widget
- X-seq: zsh-users 10351
- From: Konstantin Sobolev <kos@xxxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: java class names completion widget
- Date: Mon, 5 Jun 2006 22:40:27 +0400
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- Organization: SupportWizard
- Reply-to: kos@xxxxxxxxxxxxxxxxx
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