zsh-users
 help / color / mirror / code / Atom feed
From: Konstantin Sobolev <kos@supportwizard.com>
To: zsh-users@sunsite.dk
Subject: java class names completion widget
Date: Mon, 5 Jun 2006 22:40:27 +0400	[thread overview]
Message-ID: <200606052240.27880.kos@supportwizard.com> (raw)

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!			      


             reply	other threads:[~2006-06-05 18:40 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-06-05 18:40 Konstantin Sobolev [this message]
2006-06-07 10:47 ` Peter Stephenson
2006-06-15 15:38   ` Konstantin Sobolev
2006-06-15 16:19     ` Peter Stephenson
2006-06-15 18:41       ` Konstantin Sobolev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200606052240.27880.kos@supportwizard.com \
    --to=kos@supportwizard.com \
    --cc=zsh-users@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).