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,HTML_MESSAGE,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 25363 invoked from network); 13 Nov 2020 11:19:35 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 13 Nov 2020 11:19:35 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1605266375; b=s/E8UYofX313ejlWIfqE7LeNLNsJky8LhH8L6z1z/0Q/ibRuuKbjzI6BLJzW6xqkAU4vvCOcLG hHY0vl5Zzf4MKV5ChjjVoVVJoZxt89lgUz4VOcHz6wqCXruMeHKMqEwZhs0POuJC814ydx1iM1 nEdHcW6elF9SQGydILDy05kQxYo2hXyNrqsZAByCpEOAD7Ih6PzG+t/vEjKDmwvtMPsK2QbdSl dyCHChGgxi8dfUJY9qj4UL6tazt6f1kPo8yoWmFzMBq7WhCuaya+FTMWfRappf5mAnc046hG9d TAegm364WmrPzzjzchpwS1KhbMiBk72V5xTqrgx1d+zXmQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-io1-f47.google.com) smtp.remote-ip=209.85.166.47; 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=1605266375; bh=pE9KzI0yzSm7gCzmxkq6BT+ekY7BxB9fqTCc3cr7c2E=; 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=vmkFKA5Z/ukxP4XaNENWszhPQYixshvAHQDs3t1bGzqyq3Z/AZn3FpJU5gCsr/4e5ZtI25AxAb MRF/2bKCuJahMThaOHRhgq6f/s46XOKD1E5tAE+qwbueSq+SZDFUtuUFNkMTMwFYDoQqwU1K+1 XgyDhX7FBG1ECSG2aRzjyEVnA49SH9JROi99dASgm5pofPdBbTqF/NbjP50ki8+zAE+2VXNAEf HERIatxpvFE5rUBWIvfz82BC+HIbHoe5iLf5J6PhJGYZD5wYneHnSWXwkp2QqGKR/M5nXxR3e7 LnBv1WgZ4HjOSwuM0KGJLV6b1cY1QisQESXGTPEXkjwyLQ==; 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=Mz0gkOhsv/3d0bdxrnoTfXjf4i4HGw3kq5C1G5xuzl4=; b=Kk5IJofyvTySB+6/PjRFXJeuIJ EnhH0fQnRpt6Tbjzaz8fIcPrRjRLi8Y8k0EnBChHgnk3UCSXcgxbPyzGhvcbxhv/TIWNBiYJ9fCrB C/b7BZweTdCmH7PAcEf/Vf/be87zt7eqCNs1y9pa4A8sBo9XTF+RFGucNr3ZlbCjYEPNon8bcKiPM UF675g5OjQ6PGeGwcs5ZmSTbaKcrfycTuL6sDQauGY46anEJEKfKPD54H0Ubkj8ufQ6GMjBuYqpgf 5FOT+VN5E7Utkc95sWTuX2POXkzpeN8pC8H7O3F1o3JoyhqD9nOlH+EGuJtJT+5qqE09WHjdh6oF5 Q7MP+KpQ==; Received: from authenticated user by zero.zsh.org with local id 1kdX77-000348-2f; Fri, 13 Nov 2020 11:19:33 +0000 Authentication-Results: zsh.org; iprev=pass (mail-io1-f47.google.com) smtp.remote-ip=209.85.166.47; dkim=pass header.d=gmail.com header.s=20161025 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-io1-f47.google.com ([209.85.166.47]:34936) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1kdX6i-0002hn-Qt; Fri, 13 Nov 2020 11:19:09 +0000 Received: by mail-io1-f47.google.com with SMTP id n12so9409835ioc.2 for ; Fri, 13 Nov 2020 03:19:08 -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=Mz0gkOhsv/3d0bdxrnoTfXjf4i4HGw3kq5C1G5xuzl4=; b=ntt65FveUfAYRCU2/wimaMbOdCGjKRPn7uNUjZa5fxvs5PxFb/Xzy1fI1FRLhOMRvW G31ofhsyvWjw2H6V3ByySeKQnxFAzkMVHZHSpJ3h7AaEQE19YTWSf43Css5Ik5hZ4Dqu 3bZDEyDS+z8PHTQ03PZkaxQehB286UZ3RnRHGCCDFev75wDh1/h8z+6H/9AcPoSxuYLs 1PEen1bj0vaMo2SBdNWRs95pZJ8bdlvHQhFjAnbSlKXr2hn24LHAdMm+0/kIJicTNpE0 IPEqet8WQnsBzNh92GEOVBV77cf8M8eKwmFGbFJBFw0wix6j4utJqG6zrfqIuBwfP75q nEjQ== 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=Mz0gkOhsv/3d0bdxrnoTfXjf4i4HGw3kq5C1G5xuzl4=; b=miCt4eopT0yy9XhELl4IWw/PvbvT1JXfl5jTAtE3dHi44zL7x/eR6XmTTP7yR/jb8n qhm6ELyl4zvt5+tZCV1yXuTU/WDG1Qkl9O0xYqXtageqqo1mC/NGgUQjmn+NJB8ZYo8a pz5Z7V5pHw44cQpfx8cQDl9Os0A5N8nafjK+DO8mgvnBl9AHRoJ1yT/SkkmOyQWx2Bu5 LpbRfYU02odR6A+1kpUWYYE1K0GETxU0r+IYpxxgB9BxLt4TtnjXTtwowpt92pT1iKIo kmY06x7ijsPN3aRVV1SmMRrkCGTk0p8hBzhdy+zV4XdcqnJ7ytsz1az8l1OMLSH2tT1m RHmg== X-Gm-Message-State: AOAM532fTJRL5kdFMwyHZSj4988uEkN/gjPXrQHUg1dr+Hg9wADmkzun pFXxx0/7Yc4bk+vmotWor0huJ4UgMrsIWVovwF8= X-Google-Smtp-Source: ABdhPJxdJeYPKkvQQcUGfnibptWyfGUTB+5a0Ku2RieTwu1HpXmUYQHtQ4fdwr1qkyF+CC0mNzhGNUwCecLVDJwLnak= X-Received: by 2002:a05:6638:d52:: with SMTP id d18mr1546918jak.127.1605266347602; Fri, 13 Nov 2020 03:19:07 -0800 (PST) MIME-Version: 1.0 References: <20201113174124.cb440e381388179852e48c62@virgin.net> <20201113093443.afd8d11e641eedb409c2ee37@virgin.net> In-Reply-To: From: Roman Perepelitsa Date: Fri, 13 Nov 2020 12:18:58 +0100 Message-ID: Subject: Re: _pick_variant To: Thomas Lauer Cc: Bart Schaefer , Zsh Users Content-Type: multipart/alternative; boundary="0000000000006b375e05b3fb32d3" X-Seq: 26163 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: Archived-At: --0000000000006b375e05b3fb32d3 Content-Type: text/plain; charset="UTF-8" On Fri, Nov 13, 2020 at 11:42 AM Roman Perepelitsa < roman.perepelitsa@gmail.com> wrote: > The first solution can be generalized: > > () { > local k v > for k v in "${(kv)_comps[@]}"; do > if [[ ${functions_source[$k]:-$commands[$k]} == ~/* && > $functions_source[$v] != ~/* ]]; then > _comps[$k]=_default > fi > done > } > > This will disable programmable completions for all commands and > functions defined under $HOME that don't have their own completions. > If you have compdef calls in your dotfiles, you'll need to move them > below this stanza. > If anyone wants to use this, beware that it may increase zsh startup time. On a raspberry pi -- the slowest machine I've tested this on -- it takes 45ms. Here's a faster version that does the same thing. As is often the case with optimized zsh, it's unreadable. () { emulate -L zsh -o extended_glob local cmd MATCH MBEGIN MEND for cmd in ${${(M)${(k)_comps:/(#m)*/${${functions_source[$MATCH]:+$functions_source[$MATCH]/$MATCH}:-$commands[$MATCH]}}:#~/*}:t}; do if [[ $functions_source[$_comps[$cmd]] != ~/* ]]; then _comps[$cmd]=_default fi done fi } Roman. --0000000000006b375e05b3fb32d3 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Fri, Nov 13, 2020 at 11:42 AM Roman Pe= repelitsa <roman.perepeli= tsa@gmail.com> wrote:
The first solution can be generaliz= ed:

=C2=A0 =C2=A0 () {
=C2=A0 =C2=A0 =C2=A0 local k v
=C2=A0 =C2=A0 =C2=A0 for k v in "${(kv)_comps[@]}"; do
=C2=A0 =C2=A0 =C2=A0 =C2=A0 if [[ ${functions_source[$k]:-$commands[$k]} = =3D=3D ~/* &&
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 $functions_source[$v] !=3D= ~/* ]]; then
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 _comps[$k]=3D_default
=C2=A0 =C2=A0 =C2=A0 =C2=A0 fi
=C2=A0 =C2=A0 =C2=A0 done
=C2=A0 =C2=A0 }

This will disable programmable completions for all commands and
functions defined under $HOME that don't have their own completions. If you have compdef calls in your dotfiles, you'll need to move them below this stanza.

If anyone wants to use th= is, beware that it may increase zsh startup time. On a raspberry pi -- the = slowest machine I've tested this on -- it takes 45ms. Here's a fast= er version that does the same thing. As is often the case with optimized zs= h, it's unreadable.

=C2=A0 () {<= /div>
=C2=A0 =C2=A0 emul= ate -L zsh -o extended_glob
=C2=A0 =C2=A0 local cmd MATCH MBEGIN MEND=C2=A0 =C2=A0 for cmd in ${${(M)${(k)_comps:/(#m)*/${${functions_source[$M= ATCH]:+$functions_source[$MATCH]/$MATCH}:-$commands[$MATCH]}}:#~/*}:t}; do<= br>=C2=A0 =C2=A0 =C2=A0 if [[ $functions_source[$_comps[$cmd]] !=3D ~/* ]];= then
=C2=A0 =C2=A0 =C2=A0 =C2=A0 _comps[$cmd]=3D_default
=C2=A0 =C2= =A0 =C2=A0 fi
=C2=A0 =C2=A0 done
=C2=A0 =C2=A0 fi
=C2=A0 }

Roman.=C2=A0
--0000000000006b375e05b3fb32d3--