zsh-users
 help / color / mirror / code / Atom feed
* Is there a way to do an automatic list-choices after successful completion of directory name?
@ 2006-07-07 18:29 Nikolai Weibull
  2006-07-09 15:36 ` Nikolai Weibull
  0 siblings, 1 reply; 5+ messages in thread
From: Nikolai Weibull @ 2006-07-07 18:29 UTC (permalink / raw)
  To: Zsh Users' List

I would like list-choices to be run whenever I have completed a
directory name, e.g.,

  $ cd ~/p<Tab>

completes to

  $ cd ~/projects/

Once completed, I'd like list-choices to be called so that I can see
what directories I have under ~/projects immediately, instead of
having to type another <Tab> right after the first one.

I assume I'll have to write my own completer that I'll bind <Tab> to
that first does a call to _complete somehow, but how do I then tell if
a directory name is what has been completed?

Thanks.

  nikolai


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

* Re: Is there a way to do an automatic list-choices after successful completion of directory name?
  2006-07-07 18:29 Is there a way to do an automatic list-choices after successful completion of directory name? Nikolai Weibull
@ 2006-07-09 15:36 ` Nikolai Weibull
  2006-07-09 17:28   ` Bart Schaefer
  0 siblings, 1 reply; 5+ messages in thread
From: Nikolai Weibull @ 2006-07-09 15:36 UTC (permalink / raw)
  To: Zsh Users' List

On 7/7/06, Nikolai Weibull <now@bitwi.se> wrote:
> I would like list-choices to be run whenever I have completed a
> directory name, e.g.,
>
>   $ cd ~/p<Tab>
>
> completes to
>
>   $ cd ~/projects/
>
> Once completed, I'd like list-choices to be called so that I can see
> what directories I have under ~/projects immediately, instead of
> having to type another <Tab> right after the first one.

Yes, there is in fact a way to do what you want:

_expand-or-complete-with-list-choices-after-local-directories () {
  zle expand-or-complete
  if [[ $_lastcomp[tags] == ' local-directories ' ]]; then
    zle list-choices
  fi
}
zle -N expand-or-complete-with-list-choices-after-local-directories
_expand-or-complete-with-list-choices-after-local-directories
bindkey "^I" expand-or-complete-with-list-choices-after-local-directories

I'm sure you can come up with a better name for it, but that's what it does...

Comments?

  nikolai


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

* Re: Is there a way to do an automatic list-choices after successful completion of directory name?
  2006-07-09 15:36 ` Nikolai Weibull
@ 2006-07-09 17:28   ` Bart Schaefer
  2006-07-09 18:03     ` Nikolai Weibull
  0 siblings, 1 reply; 5+ messages in thread
From: Bart Schaefer @ 2006-07-09 17:28 UTC (permalink / raw)
  To: Zsh Users' List

On Jul 9,  8:37am, Nikolai Weibull wrote:
}
} Comments?

That technique only works in combination with this (or a similar) zstyle:

    zstyle :completion::complete:cd:: tag-order \
        local-directories path-directories


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

* Re: Is there a way to do an automatic list-choices after successful completion of directory name?
  2006-07-09 17:28   ` Bart Schaefer
@ 2006-07-09 18:03     ` Nikolai Weibull
  2006-07-09 18:15       ` Bart Schaefer
  0 siblings, 1 reply; 5+ messages in thread
From: Nikolai Weibull @ 2006-07-09 18:03 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: Zsh Users' List

On 7/9/06, Bart Schaefer <schaefer@brasslantern.com> wrote:
> On Jul 9,  8:37am, Nikolai Weibull wrote:

> } Comments?

> That technique only works in combination with this (or a similar) zstyle:
>
>     zstyle :completion::complete:cd:: tag-order \
>         local-directories path-directories

This fixes that, and also makes it work when completing files:

_expand-or-complete-with-list-choices-after-local-directories () {
  zle expand-or-complete
  if [[ $_lastcomp[tags] == ' '*(directories|files)' ' && $BUFFER[-1]
== '/' ]]; then
    zle list-choices
  fi
}

By the way, why is there a leading and trailing space in $_lastcomp[tags]?

  nikolai


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

* Re: Is there a way to do an automatic list-choices after successful completion of directory name?
  2006-07-09 18:03     ` Nikolai Weibull
@ 2006-07-09 18:15       ` Bart Schaefer
  0 siblings, 0 replies; 5+ messages in thread
From: Bart Schaefer @ 2006-07-09 18:15 UTC (permalink / raw)
  To: Zsh Users' List

On Jul 9, 11:04am, Nikolai Weibull wrote:
}
} By the way, why is there a leading and trailing space in $_lastcomp[tags]?

It's a space-separated list, so if it has a leading and trailing space
it can easily be scanned for a specific entry with

	[[ $_lastcomp[tags] = *" entry "* ]]

-- 


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

end of thread, other threads:[~2006-07-09 18:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-07-07 18:29 Is there a way to do an automatic list-choices after successful completion of directory name? Nikolai Weibull
2006-07-09 15:36 ` Nikolai Weibull
2006-07-09 17:28   ` Bart Schaefer
2006-07-09 18:03     ` Nikolai Weibull
2006-07-09 18:15       ` Bart Schaefer

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