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.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 20152 invoked from network); 21 Nov 2020 22:33:36 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 21 Nov 2020 22:33:36 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1605998016; b=TSF8/Hoy3QEW8u4HcNm1f+b925ZBywVT/XTOKKTHC8gXnhyMm5el0VBnWw5VjZnjv3gLd8PGxr 4VaO4vJWKhYdtkffzd5AgvfXKljO5x5nZTr362ea9D59G0dvib+OcxYLO64wm8K8e3NGsre5E8 T+jxiYciepWfMTtrezZ0awj3ZRpk+tLbj8KVR1r8ldNEPF9JMxsG4o4Aj25KBdAFEntA4jmiKp pDbUsW6KI2OQYLVrSEIl1z1I+nMGPP5OntDrptes4V6k7FL/cDTWudzGu5q9ITkaNO7gWwKiaa lkPoVdSo0uyW0iWB7/8GRLKU61VSd5/nhN/NJ4nVU2zwHw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-oi1-f172.google.com) smtp.remote-ip=209.85.167.172; dkim=pass header.d=brasslantern-com.20150623.gappssmtp.com header.s=20150623 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1605998016; bh=YB66mfo4BBlB/XS5WSCDmOoaOmna7uLoxER1FCSHCuE=; 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=Ac+zJrDSfMRmUGBnTj71POkAnzxjrLzAPTb/ZMFyJg5jXkmOBGOqfDICm6LzbJ5xhVhThEg9EF vC9BaEa/PluvrgTn8AF9WjhK2tTUrtA9C6e5PAuokeaA/RnJliSHGlLd+ZlDTP9r4xq0tgNHNq eTKPRa6xTX+8/WQ92NgZLhppgH2bZkwe5O1bCwu59Vfku88tffXu1jH8wjtdfkTEoeg7bAUg7S liwlrkHvI0t19VLJYZSsOfv15St14soRwMeTATD7O+7iD/3AwQ3QFMVEz+iyw3aM3bkO8nIjEl yCI9zDpWoxEKxb2P6cTNri6GgKTXv3JxaJAHioLUKgczgQ==; 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=B93spcXYGzGc+gHCjjO7pswroFLIVnXW7zOOfLhsIYk=; b=XljAiG9wqg/GuMzCvtMnxd7xtM LvLtD0WbDQ2CQgrU1l+HErabg6mSNEs+JYI070duRYPynm8jonf7uKM+NfPhEnwvnctfeEMAhKV64 Sxj63rlPugsvX5OZtGRdbl1P417XNMt7DvW8UMiWuEFmQsq1vQcvdnedL9LgY3EhOp9xvaDmn+Qr1 4OxPQKyDFp7WPuZpTbCA3w9iIL6B57tGtm4wG8lxnunpF/OcApajMEiELvohvuca1HHJuwsX2o//Y Xe67p/hpXG7AM0Y1DTL6R6xsSn3IVEM08DwQRDRiSxoKWDZiD3dZplI+Jq2hgt8VwrOKG3hSoMjBz JUW+AQUQ==; Received: from authenticated user by zero.zsh.org with local id 1kgbRi-000OXT-Be; Sat, 21 Nov 2020 22:33:30 +0000 Authentication-Results: zsh.org; iprev=pass (mail-oi1-f172.google.com) smtp.remote-ip=209.85.167.172; dkim=pass header.d=brasslantern-com.20150623.gappssmtp.com header.s=20150623 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none Received: from mail-oi1-f172.google.com ([209.85.167.172]:35050) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1kgbRQ-000ONz-3I; Sat, 21 Nov 2020 22:33:12 +0000 Received: by mail-oi1-f172.google.com with SMTP id c80so15156537oib.2 for ; Sat, 21 Nov 2020 14:33:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=B93spcXYGzGc+gHCjjO7pswroFLIVnXW7zOOfLhsIYk=; b=jjaeoszrk8pVFaedCUxzEGU0vapL1Tn8LtIcwBMe/FbPQZgvYqQc09HTzLLteoV40j GdPmvzMMBP8WPZMi91ioJ55mjcq2xNP89sK7C2QoTf9aXw0BHb1sXRCXKGfShRkbL+vg rzOmk0qAyp+zf5YkFNrOJHb4U31mTBCTT9LOMaGfD1FRcs0Fo92VFmEVzPI6hf2KG2uR ouvwjrSQ71fSbZfGHEx+VGbqyAhKbRYWZV6T5SLGSg23kRBilCMfMT852Zlu4p/5X1Rj guhUpta7nClyGVXIx32bCNTw/ikdCzpceaLYPOkE/pLuWucXvUw04jphxJRdvgH3yBwE YWtw== 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=B93spcXYGzGc+gHCjjO7pswroFLIVnXW7zOOfLhsIYk=; b=MvcgRbJ2n7GC7F6c/hy/QrKyRT83c0moTj5DLZvoQqLh2osfRGbUjokz+6TxpfH6Q5 4BnMaccUT1hsB91LHSksG3OVlikiYdA8drLUPaz7HjY8XjxXnACIlTtat3n9q5bUr/Bz 1zeshAvJP0+J46L/QESESGpNWVu2WzV0KKUMu91BEd91MMI8CBhD5b2szklNmUtwn/28 yBfGX87ycaHmpbz4xiBgV8abI/Ed6tw6/TdVUZnQ7uo1WfYrOKYJJ/gXTjvL0httdbgs jzWTa9/fpTx2UXGd3IRQW5FUUAlp8D1hct2ibzdDZSu4PehtjDECyBpeFpOed6uNbgwj +1vg== X-Gm-Message-State: AOAM533Jhu5XdmQLsFs341misBy5bpZLV6lBFJu/zybFQfrfW3UaMqGj VIvqSn03QWEY8JiI4oRMBVJuztWPTpNnI8JZEsOQCQ== X-Google-Smtp-Source: ABdhPJwl8ITpUiZUEygvkOMMp3/nJ2WZcIzednKyg3s6v4SsHDNlzTIxlXrLieZ6N5noFj0xwXBWMbsgjorVC+mIXV0= X-Received: by 2002:aca:bd45:: with SMTP id n66mr10921293oif.132.1605997990622; Sat, 21 Nov 2020 14:33:10 -0800 (PST) MIME-Version: 1.0 References: <69b1ff42-3e60-4b40-8514-9bb0690eb250@www.fastmail.com> In-Reply-To: From: Bart Schaefer Date: Sat, 21 Nov 2020 14:32:59 -0800 Message-ID: Subject: Re: Bug in completion with curly braces? To: Felipe Contreras Cc: Daniel Shahaf , Zsh hackers list Content-Type: text/plain; charset="UTF-8" X-Seq: 47587 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 Sat, Nov 21, 2020 at 1:09 PM Felipe Contreras wrote: > > On Sat, Nov 21, 2020 at 9:29 AM Daniel Shahaf wrote: > > > Consequently, brace expansion is presumably attempted for the same > > reason it s attempted when the words don't contain braces. > > But zle knows { is part of the completions Actually, it does not. Every TAB starts over from scratch with figuring out how to divide the command line into complete-able "words". It doesn't know what is going to be supplied to compadd as the set of matches until much later. Consequently the line is split before the unquoted "{" on the assumption that a brace expansion is going to follow it. It might be easier to understand/debug this by observing the effect of the following example: _foo() { compadd -Q 'stash@{0}' 'stash@{1}'; compstate[list]=keep } compdef _foo foo Looking at that with _complete_debug, the prefix is being set to "stash@" rather than to "stash@{", and you get repeated TABs cycling through "stash@{{0}" and "stash@{{1}". It's waiting for you to close the presumed brace expansion yourself. This is similar to the situation in Daniel's thread where "{" in command position is assumed to be the start of a "{ subcommand }". There's only so much completion can do to guess what a heavily overloaded token means. This appears to work around it: _foo() { local -a stashes=( 'stash@{0}' 'stash@{1}') if [[ $words[CURRENT] = *@\{ ]]; then compadd -Q -p ${words[CURRENT]%\{} ${stashes#$words[CURRENT]} else compadd -Q $stashes fi } However, that gets confused if $stashes contains e.g. 'stash@{10}' and you're trying to complete after the digit "1", so there's more refinement required. Any time there's an unquoted "{" on the line you're eventually going to run into something that wants to treat it as a brace expansion. I even tried forcing "ignorebraces" to be on during completion, but the best that does (in combo with other changes to the compadd) is to convert the word on the line to be "stash@\{" which you don't want. I've got one other idea about this but I'll send this email and think more about the other option.