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 27041 invoked from network); 28 Jul 2021 03:23:59 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 28 Jul 2021 03:23:59 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1627442639; b=TLG6rUCJBTghEoG812Mp/khxVBIO31XifC9Vy4urrv4HVTthmak6MvUeYbla+d+u0THkNGksTp vkavJ+Acr/YLbal94RgRDYsYxTtGdaWOevv5oT787PwXe7TtMKh/peQzlAgLSnyPrt8lwMnomw HDPkqjdRqh9NiA5ThMyHBT8uWANRdHxXXAveWQLWm3HOHneDZf6fN9OU09nrMqAiB2QBOJctbH FbaGldW/NTrxRATNYna1XDfZxiX9Jq2UTlflXLpbeDhexEHAraiPn0wleb1JYsQ7aEi/Z370Wu 6xkQRcDMl6IM5izDReQgJZ1VyXq42YYBNaEUIeRFOoh+XQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-yb1-f178.google.com) smtp.remote-ip=209.85.219.178; 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=1627442639; bh=+fkPxG02trBSZ7hgl+sNe62RgqRlwsRa++NgLKCvc90=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:Cc:To:Subject: Message-ID:Date:From:In-Reply-To:References:MIME-Version:DKIM-Signature: DKIM-Signature; b=lqr/QWaADmr99MprlxYTAojvxUhYn2y5DA+Inu6jJGZY6rS6FXirfHhlhDirIFQK9QHLKyg8wY LlWw4Ujrf9fgiRIAY2MKxNTnuFy6WmDBpye0nGqGgWU96V5OhZPxB4V/1sOAbQxY0NX2DbNwTg w+tMfDJSVA44rTcu12nu3MR7uPES8OOAt76Stw6fFMiJy80JeZQsQ7IYq0zZ+4Y8gYY03plTPU sMdpgmNtibJXiF0f1oT8s8xfI6v9Y5X39yQx6LO/6nwWyoK+VbIzxB1o5pAYt3eWzzJHfREG/2 Xdd56qw4WHSbqeYmwY4exudtYcZ+DsnfggXyVK/y/h1VhA==; 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-Transfer-Encoding: Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To:References: MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=pBRuuu/Pr/P0KrUr9a2atLzrIC0E4XEYtuaRJeCt30k=; b=bJnP6W0HhAMlc1yGDCN8DhzpsI jTLFDxKVS+99YbifQxnqrr44fNdXALntdkvLvH7S/ioPk+rJeoZlHKlNiG8tzwlhNWCIbGUlhSdjU joloZgRFIVnJZHvMe5EfIysxV2poKlCe06vwMETxVSQhkIcK3sOCxXVfR7AAaECkmpPUhS7oEN3B9 6hba2EaAmf9J5WTJyi3eBDk8MCAcHpqjoF+uJRPw0tFt6Chq47YMtiDZnbNAkuQmAu+EPAec5AWZd SD+jmYKJxLceW8yChotpWQV22iOiT1at1q3bnjYrQozyXWV7njvnzATSHjOZd6RiKCZtoX42nwYe2 Y9vvoizw==; Received: from authenticated user by zero.zsh.org with local id 1m8aAo-000395-0X; Wed, 28 Jul 2021 03:23:58 +0000 Authentication-Results: zsh.org; iprev=pass (mail-yb1-f178.google.com) smtp.remote-ip=209.85.219.178; 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-yb1-f178.google.com ([209.85.219.178]:36691) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1m8aAY-0002rL-7f; Wed, 28 Jul 2021 03:23:42 +0000 Received: by mail-yb1-f178.google.com with SMTP id v46so1605929ybi.3 for ; Tue, 27 Jul 2021 20:23:41 -0700 (PDT) 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:content-transfer-encoding; bh=pBRuuu/Pr/P0KrUr9a2atLzrIC0E4XEYtuaRJeCt30k=; b=WEE0XE332WZAurcj6TOB1i9wHLF+3j1qbPwEgkPWseR9uvdN/xGDciw6LtjcCczBhY C+NmY2s7pg0bHHhWgqYcUutCt75Y390G+Vut18/p/I5jPxsMAi28LptrvPLc6NJyIVv2 uykURYts6xG8PxwwnHbGr96h4a5uEStmvv/qbtOy/TV2vIs6Ts+xNLJLzlOGOmF32bBU pX0YrPoeUNzmEMffUCkwWK5rRl0jbggbZiEd7QooKnP6qvSJxoEgftiLOh/626E3XUpy EtBELCLoUNqUg13a1QhD+P1gAB2q7dj1LEGEdOT8UXpT9/iH/3rnfiTlrYGIXcXOD1zk EkIw== 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:content-transfer-encoding; bh=pBRuuu/Pr/P0KrUr9a2atLzrIC0E4XEYtuaRJeCt30k=; b=RGCgu8eb+F6ZwkPygio9OliKkRT75yRV00ytwbVvr/2X+36sFPbELtXBWV3q7RP3sx scUyRscd7glt/jjiqpcV4hkXWdRFcE5Syf3OuIW2/nFYh3KWbYdjUY9R9kgdkORelrxk oVzufLiqiWo8dKr0Ig6470PTFCxUU6AArO6tdUeuLmyTNXdSWez9TwDvyu12qY3dHQZQ 8P8aF7sljsjdWFivARvPos1nq+CL2w4fUFsJeIJCYkm/YrtXvnLefo1Ry2krmJqFmHjV bJ83snj2E1jz0FId8+2OYS+YKPWDn+j79Xj5rfEYSp3tsrJQGS2mpvMXdGd8cWoxVhLl 5UGw== X-Gm-Message-State: AOAM533uUslF+W+AmHLc+Z7A1S2OfA+ZlwVvLzZT+u0HgparoSVd7vob +eq9K8ZGOtPvAUHXHABX4PIOLNaGui9zEvxcN8ghjarv6lhgPg== X-Google-Smtp-Source: ABdhPJwORhm7gLe9eXmsIv4OKez6sghDe+KyiSDudOeZ3KwBXeiIeVdILOf7ec5XEIr95Zk/fuS2NAVN430cEYFgOo8= X-Received: by 2002:a25:dc12:: with SMTP id y18mr5147127ybe.69.1627442620554; Tue, 27 Jul 2021 20:23:40 -0700 (PDT) MIME-Version: 1.0 References: <36227-1622676235.815398@zrY_.ZerV.zhJL> <906332f9-027b-4b21-bb7f-3fd7118154af@www.fastmail.com> In-Reply-To: <906332f9-027b-4b21-bb7f-3fd7118154af@www.fastmail.com> From: Bart Schaefer Date: Tue, 27 Jul 2021 20:23:29 -0700 Message-ID: Subject: Re: [PATCH] Make _expand_alias more usable as a completer To: Zsh hackers list Cc: Marlon Richert Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Seq: 49204 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: On Sun, Jul 18, 2021 at 4:35 PM Lawrence Vel=C3=A1zquez wr= ote: > > On Sun, Jun 20, 2021, at 6:24 PM, Marlon Richert wrote: > > On Mon, Jun 21, 2021 at 12:08 AM Mikael Magnusson w= rote: > > > > > > On 6/20/21, Lawrence Vel=C3=A1zquez wrote: > > > > On Thu, Jun 3, 2021, at 5:42 PM, Marlon Richert wrote: > > > >> On Thu, Jun 3, 2021 at 2:24 AM Oliver Kiddle wrote: > > > >> > > > >> > I also wonder if this would be better done from within _command_= names > > > >> > directly but I'm not sure. Handling it in _command_names would not be sufficient for global aliases. That said, I haven't actually investigated the use of _expand_alias for global aliases. > > > >> Actually, I feel like it could instead be added to the _expand > > > >> completer. Would that be a better idea than what I presented in th= is > > > >> patch? > > > > > > > > Anyone have answers to Marlon's questions? > > > > > > If it helps, I disagree with conflating _expand_alias (expanding > > > aliases) and _expand (filename expansion). > > > > _expand already handles a lot more than just "filename expansion" > > (which it actually does not handle at all). Naming has always been a bit strange here. Yes, strictly per the docs, "filename expansion" refers to replacing a leading tilde with a path prefix, and "filename generation" is a fancy term for globbing but is considered a form of expansion. I've forgotten why we couldn't just stick with "tilde expansion" and "globbing" and leave "filename" out of it entirely, but there you are. In any event I think it's likely that Mikael was referring to globbing. > > Since alias expansion is in fact listed at > > https://zsh.sourceforge.io/Doc/Release/Expansion.html, I don't think > > it would be too weird to add it to the _expand completer. I think it's actually a bit weird to allow _expand_alias to work as a completer at all, because the completion system generally functions very badly when the matches do not consist of single words, and aliases don't usually have one-word replacements. As soon as you introduce something that contains spaces, completion gets very confused (unless you force it directly into menu completion or selection); if (otherwise) you attempt to press TAB twice to enter menu completion, it'll instead start a new completion based on the word after the rightmost space that is still to the left of the cursor. This is especially true when using compadd -U. I suspect this may be where Oliver's tests and Marlon's attempt to reproduce, went astray from one another. In any case, I'm fairly sure this is the reason that _expand_alias (before the patch) does not allow other completers to run, and similarly it's why the user is admonished to place _expand before _complete in the zstyle. > Any other feedback on 48946? Looking independently at the two questions, my feeling is I'd avoid the patch as-is, but it wouldn't be unreasonable for _expand to handle aliases (under control of a zstyle).