zsh-workers
 help / color / mirror / code / Atom feed
From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@math.gatech.edu
Subject: Re: cdablevars and cd completion in 3.1.5
Date: Tue, 1 Dec 1998 13:52:30 +0100 (MET)	[thread overview]
Message-ID: <199812011252.NAA10850@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: "Bart Schaefer"'s message of Tue, 1 Dec 1998 04:11:39 -0800


Bart Schaefer wrote:

>
> ...
>
>     compctl -x 'S[/][~][./][../]' -/ \
> 	    - 'n[-1,/], s[]' -K cdmatch -S '/' -q \
> 	    -- cd pushd
>
> ...
> 
> Now the obligatory bit of zsh arcana that still confuses me:
> 
> zsh% echo ~/zshfun
> /home/schaefer/zshfun
> zsh% cd HE
>          ^
> 	 With cursor here, this calls cdmatch and completes HOME/.
> 	 But if instead I have
> zsh% cd HE/zshfun
>          ^
> 	 With the cursor here, pressing tab does NOT call cdmatch!
> 	 Why not?  I have completeinword set.  The word under the
> 	 cursor contains a /, so it should match n[-1,/].  I expected
> 	 it to call cdmatch with 1=H 2=E/zshfun and to be able to
> 	 read HE/zshfun into $pref.  If Instead I have
> zsh% cd HOME/zn
>               ^
> 	      with the cursor here, I can complete to HOME/zshfun.
> 
> I have the feeling this is something I once knew, but maybe it needs to
> be written down somewhere.

The reason was that the `n[-1,/]' makes the part before the `/' be
ignored so that the cursor isn't in a part that is considered for
completion.
Interestingly I first parsed your compctl wrongly and that led me to a 
nice little workaround for this:

    compctl -x 'S[/][~][./][../]' -/ \
	    - 'n[-1,/] s[], s[]' -K cdmatch -S '/' -q \
	    -- cd pushd

The interesting bit is the `s[]' before the comma. It makes the
completion code use the prefix specified by `s[]' be ignored instead
of the prefix specified by `n[-1,/]'. So with this the function will
be called and we only have to change it accordingly, i.e.:

    reply=( ${${${(M)$(set):#${pref:-[A-Za-z]}*${2:h}*\=/*}:#*(PWD|:)*}%\=/*}${(M)2%%/*} )

(adding the last `${(M)...}').

Btw. I would use this compctl instead:

    compctl -/ -K cdmatch -S/ -q -x 'S[/][~][./][../]' -/ -- cd pushd


Bye
 Sven

P.S.: Yes, we probably should document the above, but I'm terribly
      busy the next few days...

--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


             reply	other threads:[~1998-12-01 13:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-12-01 12:52 Sven Wischnowsky [this message]
1998-12-01 18:09 ` Bart Schaefer
1998-12-03 10:17 Sven Wischnowsky
1998-12-07 11:58 Sven Wischnowsky

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=199812011252.NAA10850@beta.informatik.hu-berlin.de \
    --to=wischnow@informatik.hu-berlin.de \
    --cc=zsh-workers@math.gatech.edu \
    /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).