zsh-users
 help / color / mirror / code / Atom feed
* Completion... but only for the extension part
@ 2022-07-31 13:01 Thomas Lauer
  2022-07-31 15:34 ` Mikael Magnusson
  0 siblings, 1 reply; 6+ messages in thread
From: Thomas Lauer @ 2022-07-31 13:01 UTC (permalink / raw)
  To: Zsh Users

Sorry if this is in the Fine Manual but I couldn't find it (and googling
also brought no great enlightenment).

I have directories with many files in them which all have rather long
extensions (12+ chars). There can be quite a few separate extensions,
say "*.winter-music" or "*.spanish-photos"... you get the idea.

So, often I want to complete filenames as normal but sometimes I want to
limit completion to files with just one specific extension, say
"*.indonesian-videos". So... I'd like to type "*.indo" and then press
<whatever> to get "*.indonesian-videos" which in its turn will complete
only those files. The problem is the <whatever> bit... or rather a
function that does that and can be bound to <whatever>. Do I have to
write such a function or is there something in the completion system
that will do this OOTB?

Thanks for looking into that.

T


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

* Re: Completion... but only for the extension part
  2022-07-31 13:01 Completion... but only for the extension part Thomas Lauer
@ 2022-07-31 15:34 ` Mikael Magnusson
  2022-07-31 16:33   ` Thomas Lauer
  0 siblings, 1 reply; 6+ messages in thread
From: Mikael Magnusson @ 2022-07-31 15:34 UTC (permalink / raw)
  To: Thomas Lauer; +Cc: Zsh Users

On 7/31/22, Thomas Lauer <thomas.lauer@virgin.net> wrote:
> Sorry if this is in the Fine Manual but I couldn't find it (and googling
> also brought no great enlightenment).
>
> I have directories with many files in them which all have rather long
> extensions (12+ chars). There can be quite a few separate extensions,
> say "*.winter-music" or "*.spanish-photos"... you get the idea.
>
> So, often I want to complete filenames as normal but sometimes I want to
> limit completion to files with just one specific extension, say
> "*.indonesian-videos". So... I'd like to type "*.indo" and then press
> <whatever> to get "*.indonesian-videos" which in its turn will complete
> only those files. The problem is the <whatever> bit... or rather a
> function that does that and can be bound to <whatever>. Do I have to
> write such a function or is there something in the completion system
> that will do this OOTB?

There is _extensions, you probably want it on a separate keybind from
normal completion, look at the _all_matches entry for an example of
how to do that.

https://www.zsh.org/mla/workers/2014/msg00230.html is the thread for
the patch that adds _extensions if you're curious.

-- 
Mikael Magnusson


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

* Re: Completion... but only for the extension part
  2022-07-31 15:34 ` Mikael Magnusson
@ 2022-07-31 16:33   ` Thomas Lauer
  2022-08-03 16:50     ` Thomas Lauer
  0 siblings, 1 reply; 6+ messages in thread
From: Thomas Lauer @ 2022-07-31 16:33 UTC (permalink / raw)
  To: Mikael Magnusson; +Cc: Zsh Users

From: Mikael Magnusson <mikachu@gmail.com>
> On 7/31/22, Thomas Lauer <thomas.lauer@virgin.net> wrote:
> > Sorry if this is in the Fine Manual but I couldn't find it (and googling
> > also brought no great enlightenment).
> >
> > I have directories with many files in them which all have rather long
> > extensions (12+ chars). There can be quite a few separate extensions,
> > say "*.winter-music" or "*.spanish-photos"... you get the idea.
> >
> > So, often I want to complete filenames as normal but sometimes I want to
> > limit completion to files with just one specific extension, say
> > "*.indonesian-videos". So... I'd like to type "*.indo" and then press
> > <whatever> to get "*.indonesian-videos" which in its turn will complete
> > only those files. The problem is the <whatever> bit... or rather a
> > function that does that and can be bound to <whatever>. Do I have to
> > write such a function or is there something in the completion system
> > that will do this OOTB?
> 
> There is _extensions, you probably want it on a separate keybind from
> normal completion, look at the _all_matches entry for an example of
> how to do that.
> 
> https://www.zsh.org/mla/workers/2014/msg00230.html is the thread for
> the patch that adds _extensions if you're curious.

Right. That _extensions extension works, thanks for the pointer!

The only problem now is that my "normal" completions add a space after
the completion and that happens here as well. As I want to use these
completions as bases for further completions that means I have to
backspace and press <tab> again. I have no problem with the <tab> but
not adding a space would make things a bit faster. Alas I've not found
the right place to do that.

I have this

zstyle ':completion:*' menu select=2 interactive

if that helps.

Again thanks, much appreciated!

T


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

* Re: Completion... but only for the extension part
  2022-07-31 16:33   ` Thomas Lauer
@ 2022-08-03 16:50     ` Thomas Lauer
  2022-08-03 17:02       ` Bart Schaefer
  0 siblings, 1 reply; 6+ messages in thread
From: Thomas Lauer @ 2022-08-03 16:50 UTC (permalink / raw)
  To: Thomas Lauer; +Cc: Mikael Magnusson, Zsh Users

From: Thomas Lauer <thomas.lauer@virgin.net>
> From: Mikael Magnusson <mikachu@gmail.com>
> > On 7/31/22, Thomas Lauer <thomas.lauer@virgin.net> wrote:
> > > Sorry if this is in the Fine Manual but I couldn't find it (and googling
> > > also brought no great enlightenment).
> > >
> > > I have directories with many files in them which all have rather long
> > > extensions (12+ chars). There can be quite a few separate extensions,
> > > say "*.winter-music" or "*.spanish-photos"... you get the idea.
> > >
> > > So, often I want to complete filenames as normal but sometimes I want to
> > > limit completion to files with just one specific extension, say
> > > "*.indonesian-videos". So... I'd like to type "*.indo" and then press
> > > <whatever> to get "*.indonesian-videos" which in its turn will complete
> > > only those files. The problem is the <whatever> bit... or rather a
> > > function that does that and can be bound to <whatever>. Do I have to
> > > write such a function or is there something in the completion system
> > > that will do this OOTB?
> > 
> > There is _extensions, you probably want it on a separate keybind from
> > normal completion, look at the _all_matches entry for an example of
> > how to do that.
> > 
> > https://www.zsh.org/mla/workers/2014/msg00230.html is the thread for
> > the patch that adds _extensions if you're curious.
> 
> Right. That _extensions extension works, thanks for the pointer!
> 
> The only problem now is that my "normal" completions add a space after
> the completion and that happens here as well. As I want to use these
> completions as bases for further completions that means I have to
> backspace and press <tab> again. I have no problem with the <tab> but
> not adding a space would make things a bit faster. Alas I've not found
> the right place to do that.
> 
> I have this
> 
> zstyle ':completion:*' menu select=2 interactive
> 
> if that helps.
> 
> Again thanks, much appreciated!
> 
> T

Hm... simply editing the _extensions file and removing "add-space" in
line 24 seems to do the trick. Works well now.

T


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

* Re: Completion... but only for the extension part
  2022-08-03 16:50     ` Thomas Lauer
@ 2022-08-03 17:02       ` Bart Schaefer
  2022-08-03 17:44         ` Thomas Lauer
  0 siblings, 1 reply; 6+ messages in thread
From: Bart Schaefer @ 2022-08-03 17:02 UTC (permalink / raw)
  To: Thomas Lauer; +Cc: Mikael Magnusson, Zsh Users

On Wed, Aug 3, 2022 at 9:50 AM Thomas Lauer <thomas.lauer@virgin.net> wrote:
>
> > The only problem now is that my "normal" completions add a space after
> > the completion and that happens here as well.
>
> Hm... simply editing the _extensions file and removing "add-space" in
> line 24 seems to do the trick. Works well now.

Removing add-space from that line will just cause zstyle to have a syntax error:
zstyle: not enough arguments

The right thing would be to add

zstyle ':completion:*:extensions' add-space false

to your .zshrc.


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

* Re: Completion... but only for the extension part
  2022-08-03 17:02       ` Bart Schaefer
@ 2022-08-03 17:44         ` Thomas Lauer
  0 siblings, 0 replies; 6+ messages in thread
From: Thomas Lauer @ 2022-08-03 17:44 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: Mikael Magnusson, Zsh Users

----original message----
From: Bart Schaefer <schaefer@brasslantern.com>
> On Wed, Aug 3, 2022 at 9:50 AM Thomas Lauer <thomas.lauer@virgin.net> wrote:
> >
> > > The only problem now is that my "normal" completions add a space after
> > > the completion and that happens here as well.
> >
> > Hm... simply editing the _extensions file and removing "add-space" in
> > line 24 seems to do the trick. Works well now.
> 
> Removing add-space from that line will just cause zstyle to have a syntax error:
> zstyle: not enough arguments

I rechecked and that's right though it seemed to work w/o error when I
tried it. Strange.

> The right thing would be to add
> 
> zstyle ':completion:*:extensions' add-space false
> 
> to your .zshrc.

I actually did try this before editing _extensions and it had no effect
whatsoever. But I'll look into that again. Perhaps I had a typo.

Thanks T


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

end of thread, other threads:[~2022-08-03 17:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-31 13:01 Completion... but only for the extension part Thomas Lauer
2022-07-31 15:34 ` Mikael Magnusson
2022-07-31 16:33   ` Thomas Lauer
2022-08-03 16:50     ` Thomas Lauer
2022-08-03 17:02       ` Bart Schaefer
2022-08-03 17:44         ` Thomas Lauer

Code repositories for project(s) associated with this 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).