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,T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 7970 invoked from network); 24 Jun 2022 05:42:55 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 24 Jun 2022 05:42:55 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1656049375; b=BijSVOrdxnUkId7S0GsKCrdxPUsNsK7ONXc23ujNWjqu4h2CXnwxMPPdeiWDSNSWAv/TNuI1xD MjS2pu+kbEH0e+juWYK+cQ8zUjt8rXL52IGZsJd1Sf94anr/CrtzzBhkaqEFYjKUdm1z85GwIm mAihG/17aD2OW4OQTRNOmrqQbIyNI+gRp73TXNw618Rpue99Y0H54aEvh+ROZLJA8v1sf4FYCm 7MBQILnEIkagZ7r0sjSoRR4RBK7oaDs5NB2T1Vc6qEXyZ5JpWJr3gNnfniUUKhGp1kUiz3zDp/ 0usP+5RyXt0Nu9ZL9wDCCdzP5QtMCZ9/HJeuNI5EvdkArw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ed1-f42.google.com) smtp.remote-ip=209.85.208.42; 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=1656049375; bh=TmiKFT7TGHDREkXWuCJFhXq7lA0jKNjA4nlnLLeiAG4=; 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=Af5t0PfT+eX8455GPxpDb9jBLidRYWW/qWxXRkBYu8x0tJgbEAKClDPQ+TQtldmqrSDjetN6Yz lO3ebnXV/dKZJHmRfrTUeT2X6QJAb9ovEIq3hn72vDb/oi6IqNW9XREUf1Jb0c+Ca7KPaKGKRt FNbmvT/tDPrsJa/XmgiwWieKZkGZxor0kMpW6hIV2F+gskste7jkYJGunYy4hIUL0JJFPmzDcZ /BKtGs0/TulCAvUu8u0jZtC1ztUT2xCjowA13/65gz5US//yqU+MiHT5F+JlsX2LLqLmZIOsmW muGw15Y4Ny6Xxa9VgpPKy7VgyEtV/pHHAzqj4sObTX6yBg==; 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=ELSNDSYapOmDxSvtMlDIZB/3eI/iQWav9wVrtfSeh5g=; b=lw2KGPvha2zGhHNXj3I3/jEqEW hy68VkrZU9gcvhsM5I9mphDJBZOpNnKiNSxtYAkS/XvMoD7OvMjjpJyNRcjkF3Q7bNSI2DgaaOQPh iv7VJd8NMAlLez4MsvEDS8RDGdqQhQD2GvzVkBKAeIWQP9EN37A1NTnRB0RtN9bhhWxDG/Q9ab/7x epwzEaTaMQrF74r+JDlRTpDBk9X3YsM3S2cKTS2SzUsDpF8/w6ALf7cDG36x6y5pb1yq6JhqliwrT D1Ej/qUGwrSpPecgInZoA64Tal+dQMiPCKcSI+cA5hvsSZslSjKlTggnhkBGNW7bdYvcpIKYnoKfd U2Dw5nFw==; Received: from authenticated user by zero.zsh.org with local id 1o4c5l-0005gV-Vj; Fri, 24 Jun 2022 05:42:53 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ed1-f42.google.com) smtp.remote-ip=209.85.208.42; 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-ed1-f42.google.com ([209.85.208.42]:39855) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1o4c4m-0004vH-22; Fri, 24 Jun 2022 05:41:53 +0000 Received: by mail-ed1-f42.google.com with SMTP id eq6so1908930edb.6 for ; Thu, 23 Jun 2022 22:41:51 -0700 (PDT) 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=ELSNDSYapOmDxSvtMlDIZB/3eI/iQWav9wVrtfSeh5g=; b=Z33i4Ap80MQ0/skq1PFfX0Kv5T04I0z3Yp5H8aVownYIoDEFyjLEgNZFd15RN8ymYw N94EQQ7b8u8HSGdE2TT3O2p7QsLNA+9g4qPGphvRsJKMDeBIQOUG26qaatwaXAJRF+WZ h++grV9tDkWBYb+gDeYVQsw/20/pWHDbdfFW7mgxaHlZBGJJiS/M/zjNHouFhpAGYSst ahPVjdquK15gfHcZHQ1964nKHL453dm3AJziK/PoSurFc68unDkfb0a5xoYCyvszxtfQ 439V0Wl7UrfiVlhZnR7MfqN9V2y4g22dDutzX0hQLEDl30UP5LE3wOvNyIcDYDvEAIRn zwRQ== 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=ELSNDSYapOmDxSvtMlDIZB/3eI/iQWav9wVrtfSeh5g=; b=P3j7ZVudOJeppecFXzLmQdEM/TeHg0ue1nKX88iIxzgTHu0p0ObcOAEYVHkKnAljSd bR7PHJhzBb8SFI2AJWMVfoaa16+Js/VWxTnlpJ0PxNquWycKjiXrKYABexyIu+rOpMM8 olCNMrvacLWFDOAndnakUnDOq4xww84y0wjtT492W2w3pl8Bg0+xeObIz94wrKwgjCe4 M1RgT0LB5H8befURIOipeph3EXgM9VnNZ21D9FVdxM+Weag5IrVrt3nAWN4iGSK1Ld1F mEZXnxELdB700doA5lHZ73atit4tU5VSUEBgYeb8+BSb9wrZhScuxmsXnAqM91QMfH49 tOzQ== X-Gm-Message-State: AJIora9vcFgidqW9Fm2YEi9xJnzBeODQUuJHZ2Njf/U/e1DnAcQvsQ54 YuwSc8yoHZKGjJz1z05lEAO7PcQzOuXxJhqxGs5Waw== X-Google-Smtp-Source: AGRyM1tTPZpnxPMXBlvI+bFB4srFXXEerdEJsDP1nIUvdwtNlBeIEpARp4kszqIEkr8kXGrgYaZBG6bconKKsfQrvCU= X-Received: by 2002:a05:6402:3587:b0:435:b9a1:d5c5 with SMTP id y7-20020a056402358700b00435b9a1d5c5mr13255555edc.219.1656049311276; Thu, 23 Jun 2022 22:41:51 -0700 (PDT) MIME-Version: 1.0 References: <0c939d76-d9ff-e684-cbc5-70dac285491d@gmx.com> In-Reply-To: <0c939d76-d9ff-e684-cbc5-70dac285491d@gmx.com> From: Bart Schaefer Date: Thu, 23 Jun 2022 22:41:40 -0700 Message-ID: Subject: Re: Duplicate results in _python - (Re: [MINOR BUG] Duplicate results in tab-menu) To: Eric Cook Cc: Zsh Users Content-Type: text/plain; charset="UTF-8" X-Seq: 27852 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 Thu, Jun 23, 2022 at 7:42 AM Eric Cook wrote: > > On 6/23/22 05:54, Morten Nissov wrote: > > In some cases, when I tab to open the menu everything is duplicated, see below for example > > Just the group-name and list-dirs-first styles being empty string and true are needed to cause the problem. There are some interacting things going on here. First, _python uses #compdef -P python[0-9.]# This means to first try completions for commands matching the pattern, and then try completions for any other context that matches, which in this case happens to be -default-. This is handled by _dispatch, which (after discovering that "python3" matches the pattern), sets _compskip=default to indicate that it should not try the -default- context after all, and then calls _python. Unfortunately _python calls _normal which sets _compskip='' again. _normal is expecting _compskip to have come from _main_complete, but instead it clobbers the local in _dispatch, so when control eventually returns there, _dispatch goes ahead with completing for -default-. This would be invisible except that list-dirs-first causes the results of these two different contexts to be placed in separate completion groups, and then group-name prevents them from being mutually de-duplicated. The trouble here is that the completion invoked by _dispatch is explicitly allowed to change _compskip to control the behavior of _dispatch. It just happens that any completion that relies on calling _normal may do so incorrectly. Now, as it happens there's an undocumented option of _normal to prevent it from doing this, but using that option breaks the python3 completion because the -default- context is needed for the "script argument". So the fix appears to be to make _compskip local to _python, which seems a bit icky because it doesn't help with any other completions that may have it wrong. Better suggestions? diff --git a/Completion/Unix/Command/_python b/Completion/Unix/Command/_python index e5bac18bb..2711b8fd3 100644 --- a/Completion/Unix/Command/_python +++ b/Completion/Unix/Command/_python @@ -3,7 +3,7 @@ # Python 2.7 # Python 3.9 -local curcontext="$curcontext" state state_descr line +local curcontext="$curcontext" state state_descr line _compskip="$_compskip" typeset -A opt_args local -a args