zsh-workers
 help / color / mirror / code / Atom feed
From: Felipe Contreras <felipe.contreras@gmail.com>
To: Oliver Kiddle <opk@zsh.org>
Cc: Bart Schaefer <schaefer@brasslantern.com>,
	Daniel Shahaf <d.s@daniel.shahaf.name>,
	 Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: Bug in completion with curly braces?
Date: Tue, 24 Nov 2020 23:06:15 -0600	[thread overview]
Message-ID: <CAMP44s2d5+yHtdCvGDW92vfcbpV=Wn3+-yG74EdST-dJXFZn2A@mail.gmail.com> (raw)
In-Reply-To: <23476-1606260115.748247@tHME.aGU-.iDnX>

On Tue, Nov 24, 2020 at 5:22 PM Oliver Kiddle <opk@zsh.org> wrote:

> Looking at the bash example in 30136, it would appear that quoting
> is left up to the completion function. Is that always true for bash
> completions? Matches are added with an unquoted trailing space but also
> some quoted spaces. To get it to pass through compgen, it seems two
> levels of quoting and removing space from IFS was necessary. Is this
> idiom common?

It is common to modify IFS in order to add the correct elements to the
COMPREPLY array. As of the multiple levels of quoting I don't know
what you mean. What do you want to add?

> We could do something like the following in bashcompinit to special case
> only space suffixes:
>
> -      compadd -Q "${suf[@]}" -a matches && ret=0
> +      compadd "${suf[@]}" - "${(@)${(Q@)matches}:#*\ }" && ret=0
> +      compadd -S ' ' - ${${(M)${(Q)matches}:#*\ }% } && ret=0

Yes, that should work. Although I think bash would add two spaces if
-o nospace isn't specified.

Recently I tried to do something similar, which left me wondering; why
isn't there a way to specify the suffix already present in the words?

For example Completion/Base/Completer/_expand has code to split into
dir, space, and normal arrays, and add different suffixes to each one
of them.

It would be much easier to somehow say "consider the X ending a suffix".

> For the more general case, we'd need to identify characters
> with one-level of quoting. Or do a limited number of special cases cover
> real-world usage?
>
> Ultimately there's always going to be a mismatch between what needs
> quoting in bash and in zsh. Note that in bash no quoting is needed for
> git stashes:
>
> bash$ echo stash{1}
> stash{1}
>
> So a bash completion for git didn't need to add quotes - hence this
> whole discussion. Perhaps we could add an option to allow that. Stuff
> like @\{1\}.. is also common in git.

Personally I would like to see "stash@{0}" completed, not
"stash@\{0\}", but anything is better than no completion.

> If completion that comes with git is really a lot faster, I think you'd
> be better served by finding out why and adding styles to zsh's
> completion to allow it to take a faster, more rudimentary approach in
> certain cases. It may even already be possible by disabling the right
> tags.

Yes, but it's not an easy task.

In the zsh git completion everything creates a huge tree of functions
of functions of functions. Even after I find the actual code that is
doing something, that would only be for one case, then I have to go to
the next one. And that would be only for one command.

In the git bash completion it's just one function, and all the
commands call that function, so it's much easier to understand.

I sent a patch to call git's __git_complete_revlist from inside zsh's
git completion, to showcase one way how this "fast" mode could work.

Cheers.

-- 
Felipe Contreras


  reply	other threads:[~2020-11-25  5:06 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-20  1:50 Felipe Contreras
2020-11-20  2:52 ` Mikael Magnusson
2020-11-21 15:28 ` Daniel Shahaf
2020-11-21 21:08   ` Felipe Contreras
2020-11-21 22:32     ` Bart Schaefer
2020-11-22  0:37       ` Felipe Contreras
2020-11-22  2:28         ` Bart Schaefer
2020-11-22  2:58           ` Felipe Contreras
2020-11-22 20:35             ` Bart Schaefer
2020-11-22 21:20               ` Bart Schaefer
2020-11-23  3:03               ` Daniel Shahaf
2020-11-23  7:15                 ` Bart Schaefer
2020-11-23  6:46               ` Felipe Contreras
2020-11-23  7:17                 ` Bart Schaefer
2021-04-18 21:43                   ` Bart Schaefer
2020-11-23 17:31                 ` Bart Schaefer
2020-11-24 23:21                   ` Oliver Kiddle
2020-11-25  5:06                     ` Felipe Contreras [this message]
2021-12-02 19:45                       ` PATCH: bashcompinit quoting (was Re: Bug in completion with curly braces?) Oliver Kiddle

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='CAMP44s2d5+yHtdCvGDW92vfcbpV=Wn3+-yG74EdST-dJXFZn2A@mail.gmail.com' \
    --to=felipe.contreras@gmail.com \
    --cc=d.s@daniel.shahaf.name \
    --cc=opk@zsh.org \
    --cc=schaefer@brasslantern.com \
    --cc=zsh-workers@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).