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 12338 invoked from network); 5 Jan 2022 20:23:51 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 5 Jan 2022 20:23:51 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1641414231; b=HEq+Vx/EUtlY8eJbUV4KDi499t509uABrzAdZcJOr2EYZSx7Q5I5opIDqUh2e7zxcC8dh4jucU ySFLUPR931Ac0JhGx3edDoTgUdynI+P0yHfEMc4E1hrB4qV+ZJxcaW1mBCKLwSt10H/ib5T/d9 3WVVkzlpby8YkHz7AXEc8P+G/g6aWBB68IfE7EiUTD33J9b2Dg+XaNr6s5/SP45aZ6UO5yBuvf 5cSCePYQL4C/ggv8hZ+dhTeOsFSohb8ya2XL/R9no0VtDVCUc57pJGd6OuHIChJIa4n05rN9m1 26IBvlgYQrqGfLMfAJTHwj8tB1Vx5hOfYP0GDVWfyF9YLQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (pepin.polanet.pl) smtp.remote-ip=193.34.52.2; dmarc=none header.from=polanet.pl; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1641414231; bh=4Ty0ep/1ad/VSSSkOOmtjzVbYWbBF/HAqMXrKaOBKao=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:DKIM-Signature; b=hXmUuHGwA6+0Fy3mJvoeoYGA02Ie4W4UPe0JBE1MyHbMbszfOSIeMyiitKtnE8bXLHeL2nb0dc ji6lg6eQ9KQCWsRnAbFnWnXx+jq+e00i71dpOEqik5d3OSlGNjXGxQMgxXvkDENX0nxYq95ew7 zhfLKdRYdqFORjKDxWkskZv21FqivfsqLjxlB8a++Xys2OUxcAoaPOmOyAakvPxw7ne//Nuk+q /vRGIhG/i5HENG4XyDsEyJD85KKq+Tau84zVEaDYCbDaKfMP9VHLkl2uqrvH2W3drb8lU07UAz Uotq+VfnRzZr27QqfM4XUMLz4jRdaQxFBfUky/1tGxNeAg==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=sfJ/bGcL1hOz7Fx8y+H2fueQL5af2GVICZ55oD9uKdo=; b=Q3ONmFUsUzcbKcHkRCJKwDAEEA tjjBuKy4c0+kr0eqshXfCnLTiNLJ8GYWAzZRlo5a0A4t+jq7wn6uKN9/Vd1HOgOj3710ikPLy29W3 yhSnQLsadA1wx8nkL4ZPxRfpcKSQ0BTw7ssEe4OuCmEyLBWrH7PnbteBoY4fovy4MZgJoWJmWuv8+ FaQ6LMknhBV8Knd6FSqpG5EWhgF+n2B13FGg3SJuqwib/cXeZLntqGwPLGj+8/BO7pPfXIf0uVeQG dRBBma8i077jG49qk8pNUp9chQf3IeQMLmldVmJjOzELYHJ7fB50K01txS8YBdV8IVq1ObXioaoUF QruKruEQ==; Received: from authenticated user by zero.zsh.org with local id 1n5Cp4-000DBI-HC; Wed, 05 Jan 2022 20:23:50 +0000 Authentication-Results: zsh.org; iprev=pass (pepin.polanet.pl) smtp.remote-ip=193.34.52.2; dmarc=none header.from=polanet.pl; arc=none Received: from pepin.polanet.pl ([193.34.52.2]:51106) by zero.zsh.org with esmtps (TLS1:DHE-RSA-AES256-SHA:256) id 1n5Cgt-000Bwl-Md; Wed, 05 Jan 2022 20:15:23 +0000 Date: Wed, 5 Jan 2022 21:15:23 +0100 From: Tomasz Pala To: Bart Schaefer Cc: Zsh Users Subject: Re: _complete: insert unambiguous when globbing Message-ID: <20220105201522.GA6768@polanet.pl> References: <20220103123903.GA20434@polanet.pl> <20220105194643.GA13958@polanet.pl> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-2 Content-Disposition: inline In-Reply-To: <20220105194643.GA13958@polanet.pl> User-Agent: Mutt/1.5.20 (2009-06-14) X-Seq: 27452 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: On Wed, Jan 05, 2022 at 20:46:43 +0100, Tomasz Pala wrote: > However since it sacrifices ZLE-provided pattern it's not perfect. > > $ cd empty > $ 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 2*04[tab] => 2021.12.3 > files > 2021.12.30-14:41:04.xz 2021.12.31-14:41:04.xz > > so the compstate[old_list]=keep was required for the second [tab] not to > follow the updated ZLE contents. It works like a charm, but I wonder - > what cases would be broken by compstate[old_list]=keep with such a weak > condition? It would be much safer to have something like: > > if [[ $PREFIX = *'*'* ]]; then > compstate[pattern_insert]=not_menu > compstate[eat_globbing]=yes > elif [ "$compstate[eat_globbing]" = 'true' ]; then > compstate[old_list]=keep > fi > > but I can't find a way to pass this down. OK, this was pretty straightforward: if [[ $PREFIX = *'*'* ]]; then compstate[pattern_insert]=not_menu _eat_asterisk=true elif [ "$_eat_asterisk" = 'true' ]; then compstate[old_list]=keep fi It sacrifices *-using glob only (more robust test required?) because that signals rough pattern (we do not want to break some refined ones). And the problem is "provided pattern" vs "unambiguous prefix"... In general this problem is not trivial, since preserving the ZLE-provided pattern while completing unambiguous part would require to distinguish, how much of that pattern was already consumed and needs to be dropped, preserving the rest; the remaining part must match the same items being prepended by the unambiguous part. Having said that - does this behaviour deserve upstreaming with it's own zstyle, or is it too hacky? This allows for incremental completion with repeating (manual) globbing provisioning, which seems fine for some quick and dirty patterns like *z (for *.xz files), tastes best with undo/redo in finger memory. -- Tomasz Pala