zsh-users
 help / color / mirror / code / Atom feed
From: Konstantin Sobolev <kos@supportwizard.com>
To: Peter Stephenson <pws@csr.com>
Cc: zsh-users@sunsite.dk
Subject: Re: java class names completion widget
Date: Thu, 15 Jun 2006 19:38:36 +0400	[thread overview]
Message-ID: <200606151938.36646.kos@supportwizard.com> (raw)
In-Reply-To: <200606071047.k57AljuP028426@news01.csr.com>

Hi Peter

On Wednesday 07 June 2006 14:47, Peter Stephenson wrote:
> (I'm going to assume you're already using the new completion system,
> which seems to be the case.)
yes

> You can actually do the case matching element within zsh without any new
> code; the difficult bit is the combination of completion and finding
> files, but that's difficult to hook in to completion regardless of
> whether the expansion is done inside or outside the shell.  Here's how
> you do the basic completion (given the problems this probably isn't what
> you want, so I'll look at another method later).  The following adds the
> smash case completion to the context after javac:
>
> zstyle ':completion:*:javac:*' matcher 'r:|[A-Z]=* r:|=*'

[skip]
Yeah, I've already played with this stuff. As you point out below, it doesn't 
search thru the nested folders, which is a very desired behaviour.
[skip]

> So instead let's hijack the _expand completer and provide a front end.
> The trouble with making this the normal contextual completer in place of
> _java is that you'll lose all the features of that and need to merge
> together what you want.  Hence what I suggest you do is use a separate
> completion when you want the special behaviour.  Then you'll have to
> remember to type a different key sequence for this, say C-x j.
>
> Here's the full code; put it in a file (say _expand_java_path) in your
> function path:
>
> #compdef -k complete-word ^xj
> local MATCH MBEGIN MEND
> # Turn the start of the string on the line into **/ followed
> # by the original prefix with upper case letters followed
> # by [^[:upper:]]# which matches any number of consecutive
> # non-upper-case characters.  This relies on the fact that
> # the completion system uses the EXTENDED_GLOB option.
> PREFIX="**/${PREFIX//(#m)[[:upper:]]/${MATCH}[^[:upper:]]#}"
> # Replace the end of the string similarly, adding *.java to
> # the pattern
> SUFFIX="${SUFFIX//(#m)[[:upper:]]/${MATCH}[^[:upper:]]#}*.java"
> # Now we've got a zsh recursive matching pattern; for example
> #   SHMa
> # has turned into
> #   **/S[^[:upper:]]#H[^[:upper:]]#M[^[:upper:]]#a*.java
> # Let the normal _expand completer get to work.
> _expand "$@"
>
> (Four lines of active code for the whole thing!)
>
> Those are the basics; there are many, many possible bells and whistles
> since all the features of the completion system are available for
> offering you matches, and actually the _expand completer does a bit to
> much work for us; we just want the globbing effect.
>
> In particular, the behaviour with ambiguous expansions could be better
> configured.  _expand turns on menu completion when inserting.  Currently
> it will cycle through possible expansions, then all expansions, then the
> original pattern (though it's not the original, it's the hacked version
> from _expand_java_path so isn't much use).  You can use the tag-order
> style to help.

Cool, this is what I've expected to get :)
It works, but how can I force it to use menu completion instead of cycling? 
Playing with 
zstyle ':completion:*' menu select
gives a bit weird effect:
(with descriptions turned on)

kos@kos ~/work/jrs $ S<^xj>
kos@kos ~/work/jrs $ src/org/kos/jrs/ShowCommand.java
---- expansions
src/org/kos/jrs/ShowCommand.java                                               
tests/org/kos/jrs/SubscriptionManagerMock.java
src/org/kos/jrs/SoftHashMap.java                                               
tests/org/kos/jrs/SubscriptionManagerTest.java
src/org/kos/jrs/SubscriptionManagerImpl.java                                   
whack/trunk/source/java/org/jivesoftware/whack/container/ServerContainer.java
src/org/kos/jrs/SubscriptionManager.java                                       
whack/trunk/source/java/org/jivesoftware/whack/SocketReadThread.java
src/org/kos/jrs/swap/SwapFileWritingContainer.java                             
whack/trunk/source/java/org/jivesoftware/whack/util/StringUtils.java
src/org/kos/jrs/swap/SwappableObjectContainer.java                             
whack/trunk/source/java/org/xmpp/packet/StreamError.java
src/org/kos/jrs/swap/SwappingMap.java
---- all expansions
---- original
src/org/kos/jrs/ShowCommand.java src/org/kos/jrs/SoftHashMap.java 
src/org/kos/jrs/SubscriptionManagerImpl.java 
src/org/kos/jrs/SubscriptionManager.java sr ...
**/S[^[:upper:]]#*.java
kos@kos ~/work/jrs $ src/org/kos/jrs/ShowCommand.java

As I understand it tries to show the menu but by some reason fallbacks to 
cycling.

Thanks a lot :)

-- 
/KoS
* Is this the party to who I am typing to?			      


  reply	other threads:[~2006-06-15 15:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-06-05 18:40 Konstantin Sobolev
2006-06-07 10:47 ` Peter Stephenson
2006-06-15 15:38   ` Konstantin Sobolev [this message]
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=200606151938.36646.kos@supportwizard.com \
    --to=kos@supportwizard.com \
    --cc=pws@csr.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).