zsh-users
 help / color / mirror / code / Atom feed
* cd completion and CDABLE_VARS
@ 2004-03-11 11:45 Vincent Lefevre
  2004-03-11 12:28 ` Peter Stephenson
  0 siblings, 1 reply; 11+ messages in thread
From: Vincent Lefevre @ 2004-03-11 11:45 UTC (permalink / raw)
  To: zsh-users

When I use completion with the cd command, zsh tries to complete
to both directories and named directories, probably because I have
CDABLE_VARS set. I would like cd to complete to directories by
default, and if it is not possible (and only in this case), then
the completion to named directories is performed. How can I do
that?

I have the above behavior with both zsh 4.1.1 and zsh 4.2.0-pre-3
under Debian.

-- 
Vincent Lefèvre <vincent@vinc17.org> - Web: <http://www.vinc17.org/> - 100%
validated (X)HTML - Acorn Risc PC, Yellow Pig 17, Championnat International
des Jeux Mathématiques et Logiques, TETRHEX, etc.
Work: CR INRIA - computer arithmetic / SPACES project at LORIA


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

* Re: cd completion and CDABLE_VARS
  2004-03-11 11:45 cd completion and CDABLE_VARS Vincent Lefevre
@ 2004-03-11 12:28 ` Peter Stephenson
  2004-03-11 13:35   ` Stefan Reichör
  2004-03-11 16:26   ` Vincent Lefevre
  0 siblings, 2 replies; 11+ messages in thread
From: Peter Stephenson @ 2004-03-11 12:28 UTC (permalink / raw)
  To: zsh-users

Vincent Lefevre wrote:
> When I use completion with the cd command, zsh tries to complete
> to both directories and named directories, probably because I have
> CDABLE_VARS set. I would like cd to complete to directories by
> default, and if it is not possible (and only in this case), then
> the completion to named directories is performed. How can I do
> that?

This is an interesting question and I'm glad you asked (assuming
Oliver hasn't beaten me to it)...

There's a general procedure for things like this, whenever you have
recognisably different completions at a particular point.  Obviously,
that means `recognisable by the completion system', so it requires
someone to have thought about this in the implemenation of the function.
However, that happens to be the case here.

Go to the point where you want completion to be performed and type ^xh.
You should get something like:

tags in context :completion::complete:cd::
    local-directories path-directories named-directories  (_alternative _cd) 
    users named-directories directory-stack               (_tilde _alternative _cd) 
    users                                                 (_users _tilde _alternative _cd)

(I actually typed `cd z^xh' but it shouldn't matter much.)

Those names on the left of the list are what you want.  You now need to
tell the completion system what order you want it to show the tags:

zstyle ':completion:*:complete:cd:*' tag-order \
  'local-directories path-directories directory-stack' '*'

You may decide a different order, but the point is that
`named-directories' are not in the first set.  Note that I have tied
this to the cd command; you could used `(cd|pushd)', for example.

Now you should find you only get shown real directories and directory
stack entries, unless there aren't any.

One extra tip is that there is a widget _next_tags which you can use to
switch to the next set of tags even if the first set isn't empty.  It
switches round in a circle.  I use:

bindkey "^X^N" _next_tags

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


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************


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

* Re: cd completion and CDABLE_VARS
  2004-03-11 12:28 ` Peter Stephenson
@ 2004-03-11 13:35   ` Stefan Reichör
  2004-03-11 14:11     ` Peter Stephenson
  2004-03-11 16:26   ` Vincent Lefevre
  1 sibling, 1 reply; 11+ messages in thread
From: Stefan Reichör @ 2004-03-11 13:35 UTC (permalink / raw)
  To: zsh-users

Hi Peter!

Im rather new to the zsh. But I want to learn more.

> Go to the point where you want completion to be performed and type ^xh.
> You should get something like:
>
> tags in context :completion::complete:cd::
>     local-directories path-directories named-directories  (_alternative _cd) 
>     users named-directories directory-stack               (_tilde _alternative _cd) 
>     users                                                 (_users _tilde _alternative _cd)

When I type ^xh I get the following:
tags in context :completion::complete:cd::
    local-directories  (_alternative _cd)

How do you get the other entries?

> One extra tip is that there is a widget _next_tags which you can use to
> switch to the next set of tags even if the first set isn't empty.  It
> switches round in a circle.  I use:
>
> bindkey "^X^N" _next_tags

When I do this, I get a list of all subdirectories, no matter if I
typed already the beginning of a directory name. So I am not sure,
what this command does.


Another related question:
I want to "bookmark" some directories.
e.g.:
~/project1/subdir/wiki
~/data/txt/info1
~/scripts/python
...

I want to type only a substring of the target directory in a cd
command (something like ido in emacs)
e.g.: cd ki changes to ~/project1/subdir/wiki

Is something like this possible with zsh?

Stefan.


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

* Re: cd completion and CDABLE_VARS
  2004-03-11 13:35   ` Stefan Reichör
@ 2004-03-11 14:11     ` Peter Stephenson
  2004-03-11 14:46       ` Stefan Reichör
  0 siblings, 1 reply; 11+ messages in thread
From: Peter Stephenson @ 2004-03-11 14:11 UTC (permalink / raw)
  To: zsh-users

=?iso-8859-1?q?Stefan_Reich=F6r?= wrote:
> When I type ^xh I get the following:
> tags in context :completion::complete:cd::
>     local-directories  (_alternative _cd)
> 
> How do you get the other entries?

`setopt cdablevars' ought to be enough (it is for me starting from `zsh
-f').  _next_tags won't do anything until you have multiple sets of tags.

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


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************


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

* Re: cd completion and CDABLE_VARS
  2004-03-11 14:11     ` Peter Stephenson
@ 2004-03-11 14:46       ` Stefan Reichör
  2004-03-11 15:05         ` Peter Stephenson
  0 siblings, 1 reply; 11+ messages in thread
From: Stefan Reichör @ 2004-03-11 14:46 UTC (permalink / raw)
  To: zsh-users

>> When I type ^xh I get the following:
>> tags in context :completion::complete:cd::
>>     local-directories  (_alternative _cd)
>> 
>> How do you get the other entries?
>
> `setopt cdablevars' ought to be enough (it is for me starting from `zsh
> -f').  _next_tags won't do anything until you have multiple sets of tags.

Thanks!
setopt cdablevars is nice.

When I now hit ^xh I get the following:

tags in context :completion::complete:cd::
    local-directories named-directories      (_alternative _cd) 
    users named-directories directory-stack  (_tilde _alternative _cd) 
    users                                    (_users _tilde _alternative _cd)

Are the three lines three sets of tags?
Which line is active? The first one? Or are all entries active?

I still do not see, what _next_tags can do for me.


What is the meaning of the values in ()?

I see, that the user names are used for the name expansion. I do not
want that. How can I switch this off?

Stefan.


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

* Re: cd completion and CDABLE_VARS
  2004-03-11 14:46       ` Stefan Reichör
@ 2004-03-11 15:05         ` Peter Stephenson
  2004-03-11 15:28           ` Stefan Reichör
  0 siblings, 1 reply; 11+ messages in thread
From: Peter Stephenson @ 2004-03-11 15:05 UTC (permalink / raw)
  To: zsh-users

> When I now hit ^xh I get the following:
> 
> tags in context :completion::complete:cd::
>     local-directories named-directories      (_alternative _cd) 
>     users named-directories directory-stack  (_tilde _alternative _cd) 
>     users                                    (_users _tilde _alternative _cd)

Sounds like you need to read zshcompsys for some orientation.  (I don't
mean to claim that's necessarily as enlightening as you might wish.)

As I said before, the names on the left are the tags.  What I didn't say
was the names in parentheses are the functions implementing completion
for those tags.  This gives you a hint about what the tags are used for.

_alternative is a utility function and we should probably suppress it
from the list since it doesn't generate its own completions (I think
that's easy to do but I haven't looked at the code).

There's no precedence until you use tag-order as I described before.
The lines are simply to associate tags with different completers.

> I see, that the user names are used for the name expansion. I do not
> want that. How can I switch this off?

Instead of putting '*' in the last value in tag-order, just put
in named-directories, giving

zstyle ':completion:*:complete:(cd|pushd):*' tag-order \
  'local-directories path-directories directory-stack' 'named-directories'

This time I've added pushd explicitly.  Note that it is harmless to add
tags which the completer in question doesn't actually use.

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


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************


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

* Re: cd completion and CDABLE_VARS
  2004-03-11 15:05         ` Peter Stephenson
@ 2004-03-11 15:28           ` Stefan Reichör
  2004-03-11 15:45             ` Peter Stephenson
  0 siblings, 1 reply; 11+ messages in thread
From: Stefan Reichör @ 2004-03-11 15:28 UTC (permalink / raw)
  To: zsh-users

Hi Peter!

>> When I now hit ^xh I get the following:
>> 
>> tags in context :completion::complete:cd::
>>     local-directories named-directories      (_alternative _cd) 
>>     users named-directories directory-stack  (_tilde _alternative _cd) 
>>     users                                    (_users _tilde _alternative _cd)
>
> Sounds like you need to read zshcompsys for some orientation.  (I don't
> mean to claim that's necessarily as enlightening as you might wish.)

Thanks for the tip! I tried to read the zsh manual already.
It looks very big.

I am looking for a step by step guide (a tutorial) to get some funky
completions working. Does something like this exist?

> As I said before, the names on the left are the tags.  What I didn't say
> was the names in parentheses are the functions implementing completion
> for those tags.  This gives you a hint about what the tags are used for.
>
> _alternative is a utility function and we should probably suppress it
> from the list since it doesn't generate its own completions (I think
> that's easy to do but I haven't looked at the code).
>
> There's no precedence until you use tag-order as I described before.
> The lines are simply to associate tags with different completers.
>
>> I see, that the user names are used for the name expansion. I do not
>> want that. How can I switch this off?
>
> Instead of putting '*' in the last value in tag-order, just put
> in named-directories, giving
>
> zstyle ':completion:*:complete:(cd|pushd):*' tag-order \
>   'local-directories path-directories directory-stack' 'named-directories'

I tried to use this but it seems to have no effect.
I evaluated it on the command line and I tried it from .zshrc

I still get the same output from ^xh

Does the zstyle statement only affect the completion order? I want to
exclude the user completion from the cd command.

Stefan.


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

* Re: cd completion and CDABLE_VARS
  2004-03-11 15:28           ` Stefan Reichör
@ 2004-03-11 15:45             ` Peter Stephenson
  2004-03-11 15:55               ` Stefan Reichör
  0 siblings, 1 reply; 11+ messages in thread
From: Peter Stephenson @ 2004-03-11 15:45 UTC (permalink / raw)
  To: zsh-users

> I am looking for a step by step guide (a tutorial) to get some funky
> completions working. Does something like this exist?

Try http://www.zsh.sunsite.dk/Guide/ chapter 6, although that's not
perfect.

Otherwise wait for the forthcoming `From Bash to Zsh: Conquring the
Command Line' by Kiddle, Peek and Stephenson, due from Apress in June.

> > zstyle ':completion:*:complete:(cd|pushd):*' tag-order \
> >   'local-directories path-directories directory-stack' 'named-directories'
> 
> I tried to use this but it seems to have no effect.

Yep, sorry, you need:

zstyle ':completion:*:complete:(cd|pushd):*' tag-order - \
  'local-directories path-directories directory-stack' 'named-directories'

The `-' means don't try anything else, otherwise they are added at the
end of the list.  This is in the manual entry for the tag-order style.

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


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************


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

* Re: cd completion and CDABLE_VARS
  2004-03-11 15:45             ` Peter Stephenson
@ 2004-03-11 15:55               ` Stefan Reichör
  0 siblings, 0 replies; 11+ messages in thread
From: Stefan Reichör @ 2004-03-11 15:55 UTC (permalink / raw)
  To: zsh-users

Hi Peter!

>> I am looking for a step by step guide (a tutorial) to get some funky
>> completions working. Does something like this exist?
>
> Try http://www.zsh.sunsite.dk/Guide/ chapter 6, although that's not
> perfect.

Thanks, http://zsh.sunsite.dk/Guide/zshguide06.html seems to be a
good starting point

> Otherwise wait for the forthcoming `From Bash to Zsh: Conquring the
> Command Line' by Kiddle, Peek and Stephenson, due from Apress in June.

Sounds interesting

>> > zstyle ':completion:*:complete:(cd|pushd):*' tag-order \
>> >   'local-directories path-directories directory-stack' 'named-directories'
>> 
>> I tried to use this but it seems to have no effect.
>
> Yep, sorry, you need:
>
> zstyle ':completion:*:complete:(cd|pushd):*' tag-order - \
>   'local-directories path-directories directory-stack' 'named-directories'
>
> The `-' means don't try anything else, otherwise they are added at the
> end of the list.  This is in the manual entry for the tag-order style.

Yepp. That works :-)
A minor issue is, that ^xh still shows the users tag.

Stefan.


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

* Re: cd completion and CDABLE_VARS
  2004-03-11 12:28 ` Peter Stephenson
  2004-03-11 13:35   ` Stefan Reichör
@ 2004-03-11 16:26   ` Vincent Lefevre
  2004-03-11 16:41     ` Vincent Lefevre
  1 sibling, 1 reply; 11+ messages in thread
From: Vincent Lefevre @ 2004-03-11 16:26 UTC (permalink / raw)
  To: zsh-users

On 2004-03-11 12:28:17 +0000, Peter Stephenson wrote:
> Go to the point where you want completion to be performed and type ^xh.
> You should get something like:
> 
> tags in context :completion::complete:cd::
>     local-directories path-directories named-directories  (_alternative _cd) 
>     users named-directories directory-stack               (_tilde _alternative _cd) 
>     users                                                 (_users _tilde _alternative _cd)
> 
> (I actually typed `cd z^xh' but it shouldn't matter much.)
> 
> Those names on the left of the list are what you want.  You now need to
> tell the completion system what order you want it to show the tags:
> 
> zstyle ':completion:*:complete:cd:*' tag-order \
>   'local-directories path-directories directory-stack' '*'

Thanks.

BTW, in my case, before using the above zstyle, when I did

  cd pri[TAB]

I got:

  princell  private/

where princell isn't a named directory, but a user name (~princell
being his home directory). If user home directories are regarded as
named directories (as ^xh suggests), then what does "users" mean?

> bindkey "^X^N" _next_tags

I have the same problem as Stefan. I don't get the matches for the
next set of tags with it.

Concerning the keys, I also suggest "^[[Z", which corresponds to
shift-tab here.

-- 
Vincent Lefèvre <vincent@vinc17.org> - Web: <http://www.vinc17.org/> - 100%
validated (X)HTML - Acorn Risc PC, Yellow Pig 17, Championnat International
des Jeux Mathématiques et Logiques, TETRHEX, etc.
Work: CR INRIA - computer arithmetic / SPACES project at LORIA


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

* Re: cd completion and CDABLE_VARS
  2004-03-11 16:26   ` Vincent Lefevre
@ 2004-03-11 16:41     ` Vincent Lefevre
  0 siblings, 0 replies; 11+ messages in thread
From: Vincent Lefevre @ 2004-03-11 16:41 UTC (permalink / raw)
  To: zsh-users

On 2004-03-11 17:26:21 +0100, Vincent Lefevre wrote:
> > bindkey "^X^N" _next_tags
> 
> I have the same problem as Stefan. I don't get the matches for the
> next set of tags with it.

Well, in the case I use '*' at the end of the zstyle line. But perhaps
I haven't understood what '*' means.

Otherwise, why isn't the information given by ^xh updated after using
the zstyle line? After changing the style, ^xh still gives the same
information, not the new style.

-- 
Vincent Lefèvre <vincent@vinc17.org> - Web: <http://www.vinc17.org/> - 100%
validated (X)HTML - Acorn Risc PC, Yellow Pig 17, Championnat International
des Jeux Mathématiques et Logiques, TETRHEX, etc.
Work: CR INRIA - computer arithmetic / SPACES project at LORIA


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

end of thread, other threads:[~2004-03-11 16:42 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-11 11:45 cd completion and CDABLE_VARS Vincent Lefevre
2004-03-11 12:28 ` Peter Stephenson
2004-03-11 13:35   ` Stefan Reichör
2004-03-11 14:11     ` Peter Stephenson
2004-03-11 14:46       ` Stefan Reichör
2004-03-11 15:05         ` Peter Stephenson
2004-03-11 15:28           ` Stefan Reichör
2004-03-11 15:45             ` Peter Stephenson
2004-03-11 15:55               ` Stefan Reichör
2004-03-11 16:26   ` Vincent Lefevre
2004-03-11 16:41     ` Vincent Lefevre

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