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 25655 invoked from network); 4 Jan 2022 00:26:08 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 4 Jan 2022 00:26:08 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1641255968; b=aS7FxShROQs9jA79s09SUlNqHxKWKiKv0xg/7EWJOsrHwAouMVesnaFKoD37C49h2gXgoLhJod XaE96KQfAW4BHiIPtB9MgZDRc93UgWeHEvAV68fuSdzJwmBYkSXLfe7XerOV4QD1s4dQKY/bHl c6lVe6BLn4T7cFr1EEBF0WpvjeQOYOCFqUkuug9cpIYgxPIXkAhTZvZWqgFQjqTWU/gJ3p7ZQO cmj3fjGy7z9lG/U+Bd6h6nj+GBbgyScrMDcloXupKMybfdGtkaWP3oqr4V3yvWD1fQQbsWTeQ6 KutzT+/rII3GGLq8vR6X7WoRyRmH797UDegP+VqO0Wwafg==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-yb1-f175.google.com) smtp.remote-ip=209.85.219.175; dkim=pass header.d=brasslantern-com.20210112.gappssmtp.com header.s=20210112 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-20210803; t=1641255968; bh=EkH0OLq/T/Wxq4JbP/uYwquvN3MHW1Kt9qyHh1ww6/w=; 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=qHh280+WpcIFMnPqT7yxFEPtE7N6rF/1K/7mnqbsMBZbPsaq3TyYUSpkRhW15sCqdsXBFIjO3i yxp4E4931smhg1OHjQoLiT1QAcY5Ep8l+99OOL8qRD8V3qWgPrtLmHi+HzMt9RSaRkJb/Wk+Ih DlEAd3LC3MRCStCpVV3071TIzStbQlLQQ4IVwx5g7DsTwfuv04L/FilKR7XcaPbC5aB5oV+f3c i8Lu8Qw67Ns2J6KfQsGaA45qA9/83DMwTaNFI9fnsMxAlOkkyzk2j0AWRLeC1nma5swkBEoArS zELkcaD4nmpWE1HTPHoAKEHNZuyE+4EJ4V/JTOAwiCJP8w==; 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: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=Jj+QUhQmVRm5sGl9gnfrCIUmfYDfRaigDzGYT4HA5Lo=; b=PehBY+u1XT4otl6Wcyp5R4rSdK A1zPmwvl3x55c+qPjf1BpGNxzXP5ggww/18eFTnMOTzZ9ZsHFT2rWSIUoqyKdw7QWlUJQlgN94K9D xWm+HfgStoUzIPYWoDi6jBxhXJ4AoYgk9liqSiyu/3A+D6o3ayQ2lVg/4g8zXGaElXwCBqrXLcU7H ITBufdyPIyZ8U1c7ix6w0Hv7PO2ZJMCDeM2jMnZjXva8y5Hi0VYtNrTCWAq7krNQrE/Y/9OfVgVvU uhNwxTNRVpZRwCDahiNN1UqyboKwksDRFv1b5OsxFUke5SMRWGR7l/+DZBhfCd0XP3ZpmU/nelJcW 5Xgy56Yg==; Received: from authenticated user by zero.zsh.org with local id 1n4XeR-0008Jt-7c; Tue, 04 Jan 2022 00:26:07 +0000 Authentication-Results: zsh.org; iprev=pass (mail-yb1-f175.google.com) smtp.remote-ip=209.85.219.175; dkim=pass header.d=brasslantern-com.20210112.gappssmtp.com header.s=20210112 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none Received: from mail-yb1-f175.google.com ([209.85.219.175]:33482) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1n4Xdq-0007cO-Hk; Tue, 04 Jan 2022 00:25:31 +0000 Received: by mail-yb1-f175.google.com with SMTP id g80so59418810ybf.0 for ; Mon, 03 Jan 2022 16:25:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Jj+QUhQmVRm5sGl9gnfrCIUmfYDfRaigDzGYT4HA5Lo=; b=xdAXPcmBHJxtXJ3lVmkntEe5L/z0cWzvvxtJ6FZd2jvt//qAw6QvG7uvN5pb5K53q3 j+8N96+pwvYqItqDRfL2Utx72LcX2eKsuNQHqRhDOV7M4CAyIE+gKeokL1b0jDrALHJV 75fqs/RN8vJD79gGIyu1so4ue6Yk9toYn6gNePAO1YN31OQByvaHo9rkH1PMSmiAmwYG 3t0TghpODzmivcFUjJ6mZH3JV58gHrKLANGvVz9PMfPAqKA1dXL80RYC2nQDN/a8ApWB 0PgeNCm+bNWnhMLujpl++xkb9b/VKldXTml3KTSdAI8fckbiRjtyuxvTas8QEju3c2ga +H5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Jj+QUhQmVRm5sGl9gnfrCIUmfYDfRaigDzGYT4HA5Lo=; b=b0bNtAqReBmyrKOBOUkRBoRmXZCBksvRjS0WTJ5zz93IgN8VlZaAKMEAx+RYcNQFlX A7tGo+OQyzpneaeXV1Q9RPihZEFxtKsPywSxRYSBynUbm2nygWmyTKYfIdL4+euLBIka KFeA0kyFmwIUpGRMrek0xn/9Qem5ozDpUv7B3i4TFpxrDvvz8SlX98/T3Hzys4u2O+7d q4xQA1abugtE8k2K0+iRy9tU4lu8jBzKS1A77gA0AQK02Kz9NSbDCdgLGmrsVTibBkUd y/l7zbmxK5OELO76wvkCthiy7r6ScpsmCMEkl3HoDfa7kgVgdr13YZTyqwcZPg6wpr8n 5ZxA== X-Gm-Message-State: AOAM533uZ7InmWCADPBAG8vBT4m0/ykwYrIbZgPoTjM20p/8sOVzOtHc QFKE5c+ERLQqZtTLX4XzuDjvbvdBUZNhFbiB5lyR31/pU8xYUQ== X-Google-Smtp-Source: ABdhPJzHM6poaw4SqX776XYLhW4loJmEfVe45/OyU6DhXjg5sh9zfirNqJoSmtWP6IHTTUIyAJyr0kRUurHQE1hm2O4= X-Received: by 2002:a25:b682:: with SMTP id s2mr60366875ybj.736.1641255929255; Mon, 03 Jan 2022 16:25:29 -0800 (PST) MIME-Version: 1.0 References: <20220103123903.GA20434@polanet.pl> In-Reply-To: <20220103123903.GA20434@polanet.pl> From: Bart Schaefer Date: Mon, 3 Jan 2022 16:25:18 -0800 Message-ID: Subject: Re: _complete: insert unambiguous when globbing To: Tomasz Pala Cc: Zsh Users Content-Type: text/plain; charset="UTF-8" X-Seq: 27449 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 Mon, Jan 3, 2022 at 7:24 AM Tomasz Pala wrote: > > ls 2[tab] ==> 20 this is expected > ls 2*[tab] !=> 20 how to make this to be expanded first to > > "20", and then the regular rules to proceed (either menu complete I > always use, or _expand)? The basic problem here is that the set of common prefixes always includes the string originally on the command line when deciding whether to insert a partial result, and except in pretty unusual cases none of the results is going to include the "*" character, so the best you're going to get is to always immediately enter menu completion. You can get that with setopt globcomplete This varies a bit depending on your key bindings and completer style. The above is required when you have TAB bound to expand-or-complete, but for example with bindkey ^I complete-word zstyle ':completion:*' completer _complete _expand you can get a similar set of results, but menu completion is entered with all possible expansions instead of all matching files. > One more note - zsh knows where the first ambiguous character is, even > with globbing, as it's shown with show-ambiguity style. Hmm. When I try this with your 20{a,b,c,d}.x example, globcomplete gives "20" as the unambiguous prefix but my second formulation has only "2". This appears to be because with globcomplete on, the set of glob matches has already been calculated before entering the completion process; the prefix from the command line is determined very early in both cases. This suggests that some fiddling with the value of compstate[insert] could produce the "show prefix on first tab, enter menu on second tab" effect that I think you're asking for, at least some of the time, but I'm not sure where to do that.