zsh-users
 help / color / mirror / code / Atom feed
* Completing within colon separated paths
@ 2001-03-14 15:45 John Cooper
  2001-03-14 15:53 ` Peter Stephenson
  0 siblings, 1 reply; 4+ messages in thread
From: John Cooper @ 2001-03-14 15:45 UTC (permalink / raw)
  To: zsh-users

[ ZSH_VERSION is 4.0.1-pre-2 ]

Is there a way to have TAB complete '/usr/local' from the X (marking cursor
position) in the following:

  $ .:/home/jsc/bin:/usr/locX:/sbin:/usr/sbin:/usr/java/jdk1.3/bin

Using expand-or-complete-prefix mimics temporary insertion of a space at the
cursor position, but it seems the colon at the start of the path component
prevents the recognition for filename completion.  I've tried dabbling with
WORDCHARS, but suspect this is not the right approach...

Interestingly, when I use `vared PATH', expand-or-complete-prefix does actually
complete path components.  So what needs to be done to have the same behavior
when editing PATH "directly" on the cmd line (i.e., without `vared')?

[`vared' might not always be the way to go, e.g., when passing -classpath, plus
 several other args, to a JVM.]

Thanks,

    --- John


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Completing within colon separated paths
  2001-03-14 15:45 Completing within colon separated paths John Cooper
@ 2001-03-14 15:53 ` Peter Stephenson
  2001-03-14 16:30   ` John Cooper
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Stephenson @ 2001-03-14 15:53 UTC (permalink / raw)
  To: Zsh users list, John Cooper

> Is there a way to have TAB complete '/usr/local' from the X (marking cursor
> position) in the following:
> 
>   $ .:/home/jsc/bin:/usr/locX:/sbin:/usr/sbin:/usr/java/jdk1.3/bin

If you are using the new completion system, then it will work as long as
you are performing a parameter assignment (or it does for me).  So

$ PATH=/foo/bar:...

or

$ typeset PATH=/foo/bar:...

should perform completion correctly.  This is why it works in vared --- the
context is treated similarly to a parameter assignment.  (You still need
expand-or-complete-prefix --- I don't know if it's to be considered a bug
that the colon before is used as a word separator while the one after
isn't.)

Now everything computes?
-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Unit 300, Science Park, Milton Road,
Cambridge, CB4 0XL, UK                          Tel: +44 (0)1223 392070


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Completing within colon separated paths
  2001-03-14 15:53 ` Peter Stephenson
@ 2001-03-14 16:30   ` John Cooper
  2001-03-14 16:56     ` Peter Stephenson
  0 siblings, 1 reply; 4+ messages in thread
From: John Cooper @ 2001-03-14 16:30 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: zsh-users, John Cooper

Peter Stephenson <pws@csr.com> writes:

 > > Is there a way to have TAB complete '/usr/local' from the X (marking cursor
 > > position) in the following:
 > > 
 > >   $ .:/home/jsc/bin:/usr/locX:/sbin:/usr/sbin:/usr/java/jdk1.3/bin
 > 
 > If you are using the new completion system, then it will work as long as
 > you are performing a parameter assignment (or it does for me).  So
 > 
 > $ PATH=/foo/bar:...
 > 
 > should perform completion correctly.  This is why it works in vared --- the
 > context is treated similarly to a parameter assignment.

OK, thanks for the explanation, and it works for me too when doing an
assignment.  But I do also sometimes want it to perform completion correctly
when completing a colon separated path on a cmd line (e.g., the -classpath
argument to java or jview).  Any way to force the same behavior in this
situation?

 > (You still need expand-or-complete-prefix --- I don't know if it's to be
 > considered a bug that the colon before is used as a word separator while the
 > one after isn't.)

I've just noticed that using `setopt completeinword' seems to allow me to
complete using TAB rather than expand-or-complete-prefix.

    --- John


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Completing within colon separated paths
  2001-03-14 16:30   ` John Cooper
@ 2001-03-14 16:56     ` Peter Stephenson
  0 siblings, 0 replies; 4+ messages in thread
From: Peter Stephenson @ 2001-03-14 16:56 UTC (permalink / raw)
  To: Zsh users list, John Cooper

Peter Stephenson <pws@csr.com> writes:
> OK, thanks for the explanation, and it works for me too when doing an
> assignment.  But I do also sometimes want it to perform completion correctly
> when completing a colon separated path on a cmd line (e.g., the -classpath
> argument to java or jview).  Any way to force the same behavior in this
> situation?

The completion function that does this is called _value in the Base
subdirectory, but it's written on the assumption that you have a real
parameter whose value you are altering.  The bit you're interested in is
the stuff with

  compset -P '*:'                   # strip stuff up to last :
  compset -S ':*'                   # strip stuff after next colon
  _default -r '\-\n\t /:' "$@"      # do default completion on this
                                    # -r is passed to compadd, see zshcompwid

You probably want to decant that into another function and use _arguments
to call this where you need it.

In fact, in this particular case I rather think you need the tweak to _java
in the patch at the bottom.

> I've just noticed that using `setopt completeinword' seems to allow me to
> complete using TAB rather than expand-or-complete-prefix.

Yes, I'd forgotten I didn't have that set.

Index: Completion/User/_java
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/User/_java,v
retrieving revision 1.3
diff -u -r1.3 _java
--- Completion/User/_java	2001/01/15 09:11:33	1.3
+++ Completion/User/_java	2001/03/14 16:55:16
@@ -368,6 +368,7 @@
 
 classpath|sourcepath|bootstrapclasspath|docletpath)
   compset -P '*:'
+  compset -S ':*'
   _alternative \
     "classpath:$state:_path_files -qS: -g '*.(jar|zip)'" \
     "classpath:$state:_path_files -r': ' -/"

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Unit 300, Science Park, Milton Road,
Cambridge, CB4 0XL, UK                          Tel: +44 (0)1223 392070


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2001-03-14 16:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-03-14 15:45 Completing within colon separated paths John Cooper
2001-03-14 15:53 ` Peter Stephenson
2001-03-14 16:30   ` John Cooper
2001-03-14 16:56     ` Peter Stephenson

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).