From: Tomasz Pala <gotar@polanet.pl>
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: Zsh Users <zsh-users@zsh.org>
Subject: Re: _complete: insert unambiguous when globbing
Date: Thu, 6 Jan 2022 02:52:21 +0100 [thread overview]
Message-ID: <20220106015221.GA12608@polanet.pl> (raw)
In-Reply-To: <CAH+w=7Z_iezjS6QngRPAKyy63-J7q535DWV=-5fEw9xiVcLhNw@mail.gmail.com>
On Wed, Jan 05, 2022 at 12:11:54 -0800, Bart Schaefer wrote:
> Aha! That's given me the answer.
>
> You want something along the lines of:
>
> unsetopt globcomplete
> zstyle ':completion:*' completer _complete _match _expand
> zstyle ':completion::match:*' insert-unambiguous true
Smart one! This is nice, but this time I got other issues:
$ rpm --*er[tab]
without glob_complete, this method of finding options for SOME commands
stops working. What's the difference between ps --* and ls --* that the
latter still works?
And back to my example:
$ touch 2021.12.29-14:41:02.xz 2021.12.29-19:41:02.xz 2021.12.30-03:41:03.xz 2021.12.30-14:41:04.xz 2021.12.30-19:41:02.xz 2021.12.31-03:41:02.xz 2021.12.31-14:41:04.xz 2021.12.31-19:41:03.xz
$ ls *04[tab]
- this one is much nicer than my version, goes directly to:
$ ls 2021.12.3-14:41:04.xz (note the suffix)
with cursor __^__ placed here, on dash. However, unless I move cursor
left+right manually, pressing tab second time moves cursor to the end
with uncompletable line...
And following one fails miserably...
$ ls *z[tab]
$ ls 2021.12.-
See the dash at the end? From now on, no completion... This problem is
solved by alternating order to _expand _complete _match.
Apparently _complete _match parts doesn't work well here in that order,
however _match _complete (only!) works just like my solution without
compstate[old_list]=keep, therefore one of the following seems to work fine:
zstyle ':completion:*' completer _match _oldlist _complete
zstyle ':completion:*' completer _expand _match _oldlist _complete _prefix
But no suffix added, just like in my version.
Moreover, in this order there's no need to unsetopt glob_complete.
Am I missing something?
There is still one issue with coloring completions, that works fine with
my approach, but seems to be stuck on _oldlist:
highlights='${PREFIX:+=(*/|)(#bi)($PREFIX|$PREFIX:t)(?)(*(${LASTSEARCH})*)#*==1;32=1;31==1;32}':${(s.:.)LS_COLORS}
zstyle -e ':completion:*:*' list-colors 'reply=( "'$highlights'" "ma=44;1;33")'
With _oldlist in action the colors are not updated after prepending the
unambiguous part.
> The use of insert-unambiguous will set compstate[pattern_insert]
> correctly for you. You might also try the value "pattern" for that
> zstyle.
--
Tomasz Pala <gotar@pld-linux.org>
next prev parent reply other threads:[~2022-01-06 1:53 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-03 12:39 Tomasz Pala
2022-01-03 15:40 ` Tomasz Pala
2022-01-04 0:25 ` Bart Schaefer
2022-01-05 19:46 ` Tomasz Pala
2022-01-05 20:11 ` Bart Schaefer
2022-01-06 1:52 ` Tomasz Pala [this message]
2022-01-06 10:38 ` Tomasz Pala
2022-01-05 20:15 ` Tomasz Pala
2022-01-05 20:25 ` Bart Schaefer
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=20220106015221.GA12608@polanet.pl \
--to=gotar@polanet.pl \
--cc=schaefer@brasslantern.com \
--cc=zsh-users@zsh.org \
/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).