From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 16461 invoked from network); 25 Nov 2020 05:06:48 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 25 Nov 2020 05:06:48 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1606280808; b=s1LdGeR/4X515cNH8ga4e5Lg8zDXMRIjD9Dm5ySVYqV9Z/Tc7xz5tDkTSER3b40eFdj4k37RkR JrfP0CQHSrDIOj6YBdIUtr6U3MOmCCeceDbar97n+pWtYQzA1DTMePvcolmEorzLw8rBm90cXz eOLiiMCGDXHrbK0KK5jleOI97A55R4VO/fyT7zrEAmT5E/phpYUMq0qIYBGgWlFpVzrBlWdMRY oiH0w40qh4Ie7c+DK37FZX5RZADfL2f7jtYMbGoAUcJYpfiyFdHzhsN32WABQ+jGmP6WwGRkg9 bOW7E4WrfTYvQhzCyA2rwh75p9nXVks3BBhwJgk/NPWQDw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-wm1-f44.google.com) smtp.remote-ip=209.85.128.44; dkim=pass header.d=gmail.com header.s=20161025 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1606280808; bh=hQkK5PyPSJt8jw9jrTIsAbkJwSpXEFkvsdqfVLo99jw=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=pE9lfuQ9UacqUpGGLg542bUS4RBr6zyDGabKn4L0eWJQHH8mntUNvgQmWMtGbOdrp7nTZ3kF/x X1eytX4p30QSe2kE/PmPiiqDq/DyUMXMeN5vabEiNFuNrh+5rO+m7PEYRTApwSjRuzW5P1yeTq QS899RrB2KjkWuvSUV7xBuhLfvdW6y7D7R9y0RW3AQaArNdOdG+NCiTBbJ8aeOCcBUlZDL4wTj eBeYq0jziBWHPwVsgWT6rr5lO3lCq5Qe87NjQrhjDTOjT0RQcTJ6V91Ely0Pt0lCKlJwducJLD Eo67aTaepNBbS+tWBbplU27j/BghKOU9zdUf+d1PXbptAA==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20200801; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID :Date:From:In-Reply-To:References:MIME-Version:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=rtd9TTtsPdw0w6zSBihKqDilCR8lYl5dJnPpwS6ZuVA=; b=UfayWS5wL7sSXfy0o0p2mQE5k9 sMV6D9+NR/1t5/h0V3lmpAE1eiIQ8wa7OD9KF0nvFvaimUWIsY9avYG2hXUdDwXMUVdXYPM+Qd2JM sslhzUhjsmzPaJBTunGSzewpzQ4HaQVx1hYtrvwSgRmFLp6KbcCoFCsPqCeToNz+ewvpv4ZsZyuqQ yf9I8hvq+mtth44BCq4S3IYtRj2SfAwOchZESR8MfXNF2gmfS+8SeJnZEPAn62SGhACVK3w8XmOn/ +oIFcZQiquJcfXOdCBpVO3FzytlrfSNdk98AS/vBj6homI9RXaKBFbbCTO2KhUTrb5xRMA/R0lGcU ehJAbJAQ==; Received: from authenticated user by zero.zsh.org with local id 1khn0w-000Im9-TH; Wed, 25 Nov 2020 05:06:46 +0000 Authentication-Results: zsh.org; iprev=pass (mail-wm1-f44.google.com) smtp.remote-ip=209.85.128.44; dkim=pass header.d=gmail.com header.s=20161025 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-wm1-f44.google.com ([209.85.128.44]:38134) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1khn0e-000IG3-0s; Wed, 25 Nov 2020 05:06:28 +0000 Received: by mail-wm1-f44.google.com with SMTP id 1so929831wme.3; Tue, 24 Nov 2020 21:06:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=rtd9TTtsPdw0w6zSBihKqDilCR8lYl5dJnPpwS6ZuVA=; b=GvF8P6jL4SLdNTUpO0ITvEAPP8u3ZP1iBx8sgb3v7aj1JXJcPpFR9hXpgLCXGT//vH D2NU+UzEJmm8MF2jz57HcZwOmO1UF1BqtVGZdtdKZXGVRnp7B+v8tNOKEmbQpenlnibM 6Tr4GWfDKkBsMtXozg4xB95A4l0fhFm+OZM+yFFIaC/1eTdxRQzOL0dIsKDw6EB+1hD1 wV2UWMJb665FsuiYsgNxQ4vpLLm1bpSSVaJpjZfSwzvqtFvGyzjcqyMcbFVgQojOuBDz U3NzQflQdS+V1JF0NUxsIiqnObgQO5kGKN8LDN+7txrVWgR/wp6g0Go9G8wcdTXXi95x jrzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=rtd9TTtsPdw0w6zSBihKqDilCR8lYl5dJnPpwS6ZuVA=; b=KHOnw5jQl1ijmerK3HMMYpTvSG+9yqg+JQSmvWJ2beA49rq9c+YPbZWpXOc8x3Ok9e Sh68ir9Ad5/Ji/XLya/rYg8C3PG7OTVl1amL8Ut4m+TdC+454o83gGgTxl5pCEYOKJny L0nVFU9npN13KILcTo58BT7gWexhk74XkJutgLfi1snpJJwzDTs8+kD0Vj1QHlU6p8Y8 2wPazzRPi+w4eafgNASJtOLcH9NhrPoAz8kjmHpdASvldjDaKNMdoW88dsnhXQ7ZX9iU s6bu54jf/yhfh5TNGluDmexVYYW4P0nnFmIZl9X1x6JOm0CgqxDTijUpJlswaj+WTiRu jd9g== X-Gm-Message-State: AOAM530HGM12rCMg4GoAhI7RqAqj4k3qgoOJQfeZJVxhAeNha+k+e1j5 y1bpkcnUaDE+KkOM48e1WddJaNASvhhMwBltCHUSyaTs22YNqA== X-Google-Smtp-Source: ABdhPJz8lyilvajxlSUSzA9qztiI6B6fvl5+kq4aY8peYWpZ2oGNwEFsGHDMy/EyQF4L78pMJgGvpBCD5QZjmh6UOcc= X-Received: by 2002:a1c:41c4:: with SMTP id o187mr1816784wma.48.1606280786856; Tue, 24 Nov 2020 21:06:26 -0800 (PST) MIME-Version: 1.0 References: <69b1ff42-3e60-4b40-8514-9bb0690eb250@www.fastmail.com> <23476-1606260115.748247@tHME.aGU-.iDnX> In-Reply-To: <23476-1606260115.748247@tHME.aGU-.iDnX> From: Felipe Contreras Date: Tue, 24 Nov 2020 23:06:15 -0600 Message-ID: Subject: Re: Bug in completion with curly braces? To: Oliver Kiddle Cc: Bart Schaefer , Daniel Shahaf , Zsh hackers list Content-Type: text/plain; charset="UTF-8" X-Seq: 47620 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: Archived-At: On Tue, Nov 24, 2020 at 5:22 PM Oliver Kiddle 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