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,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 18189 invoked from network); 10 Oct 2021 12:06:46 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 10 Oct 2021 12:06:46 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1633867606; b=OB0+YP7W0+KpHSdAdhW9HKEZaVBLqIpsSBoGGyKbdVzgZs7XoKC8EMOBCNMtqHaIXWBEH3PrUc MjMCWgE9tTyVlZVrWIcBG+LvKCYnRK4QzJ9Z22oWldKWm2gI3aEmfXyErxHZpJVvJjntAHKMgV 8vASbe05iwnXJle80pdsucw4TBoqXwkmygnhli+lML+23eurDtP7OJRtUYpkyEa2krYi5CFORB niQKaZQRZ99kxVwjfO8ql3yeeIzenP+RBb/2MCUED9QpuicmDB79KDP5aEK1FouruTBUVPiu1v b+2aLYTrOskI+unXcQ9y3nfyoiOMwGDJsvZwcOFXQZSdFQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-vk1-f169.google.com) smtp.remote-ip=209.85.221.169; dkim=pass header.d=gmail.com header.s=20210112 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-20210803; t=1633867606; bh=H1TcuEg5zpAtW2UexZ9hpyug9CtYSWYhEeibg5d3DdY=; 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=gEur8f/i1MjLMvJx0ZMcfZtExWdarinjhRsI6KXhcg7JyurDzraJnk6DgdVgak1c2uFZz+d+pn icGXuImLuVq2cRRLkrKPZ7AGO/tc6EkFPjczdd0RbCI03Y4wUhSTyCnhmxKYrJHlXiRH1xQCSN zbaH9I5Td13ClBHFiiz1tIh+/Xy0gmKulbuUj5QZX+aUbI7Fmpi3VM+FzFbSe3ijiVui1KWBHj KbzrLBFshjZ9rE3l6GvikVw5g1GZQIJQeL7FrGz5lUIGsTcVB7dUcK/nIUS/FHhCKwc9JmLKGq VGVUsDYGZQx/G09HLDYj+M8tPmYsBkhflPLDZj0JEfKBmw==; 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-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=VPKS0yuzUqm9jHiU5ju7fI+GnbzbVB5XUGmgQIPmKSg=; b=fbKEH7dUi9oXEOGzuIrJ1PAIvb WY8jNn744GItS7DNjacrdLa7IOqgZ9jJcFI/d4JoLyxSWlF3Bv0dG4vHK/C1deaTEzwrkRTEdbTdE GFa2o22ufTXtxLOQVwh2wbePqMWiHVWzbiE/eJIYsavErpbdnrz1wclYBNYwy6Ob/HIKt1HFez5O2 dWPk/aHgSYhJot4PChTEnQXZmXFfbp1svvZX0Zandtk6461pe/rbeERBmk6CWB4OGVFepXT8BkyEc diDOaAvj7cKIfqHQyRJyy1xkCxgCDpEgR5WLTgizvcn1QixAD/d1qxPBafzQ6jLLIwKYTV3A4ixAp JVqYff3A==; Received: from authenticated user by zero.zsh.org with local id 1mZXbK-000H9z-ED; Sun, 10 Oct 2021 12:06:46 +0000 Authentication-Results: zsh.org; iprev=pass (mail-vk1-f169.google.com) smtp.remote-ip=209.85.221.169; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-vk1-f169.google.com ([209.85.221.169]:39722) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1mZXaj-000GS2-MC; Sun, 10 Oct 2021 12:06:10 +0000 Received: by mail-vk1-f169.google.com with SMTP id m199so6219444vka.6; Sun, 10 Oct 2021 05:06:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=VPKS0yuzUqm9jHiU5ju7fI+GnbzbVB5XUGmgQIPmKSg=; b=eYmRA0y7qDQyrBEmeOUzMIV6spobESi69OBUlTXX3OKgM+O8AyGgWTG77t9+Tr3A7I fFjbXUmKuWyFScbhBfePE3rEXOmExtmCYxND0RtDgj8TcZjVzAMRKzIWuDsV3MARYvo7 NIUeA0OvCuMcIKH8Wo+8sk+K8pdOWhlOCr3xwt1+/tJzPNTOeXYZDTSLNch4eILQOPFO rBHDZydOsWgR23iXnlo0Qb/g1cHtTr1xn9ocsen5sfC6ss9T3A/1zFgXVnhdFnJhei72 H92nyDWbMrlk6ZxXNfKtJLF91MeEJskAnXZ0039LnMG2yykc6lst39pb20Ip5nc8oNxE p9LQ== 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:content-transfer-encoding; bh=VPKS0yuzUqm9jHiU5ju7fI+GnbzbVB5XUGmgQIPmKSg=; b=7sHGPF7maVLuG/ZlJVzoFHYpKCN+QICVr0hriFRjgIcUy9oS9iRZdKl869cPejh0jl AqllbTUwrxIKzPJ2kyWu6UtvZiDYJINSpYPGAGprvpXdDc5vDARWn7ELh0bPznXqhC0v ecFAFRZZfXJRni4AKrJmwxFl7RMyKH2N7TdGSZknd0FKPO8mOJU5FTu1IemrFIDVuMcW d3BPIC4lofO7MDiB4QKbwdzV3xxVH2R9AeeMbD3LVmxR/N2a7j2lt3fEqT5T0Xa76mKX PlaBY4qCpBJLkRevkgeumpgo4yGE0mk/cQq2EZEYHT2LsqZ2pvw5RNAtCIxSaHKg4/en cJRw== X-Gm-Message-State: AOAM533B+ARKiWxME/OfjUaV4Ag3yw7PqjDdEgKRDbFSHzlf5/7CVjuM H3anlT9FdhJYrWlh22QpRoa7zpDr4emVBiALm8rdVxyRP90= X-Google-Smtp-Source: ABdhPJyVSeFNXQIdst+G0qN5EVYiC1REWQ8XQi5NElQxuRns1kFzmJTcidAOMCaF/PSnI8ApHMlYMFqn703NdCf3/Nw= X-Received: by 2002:a1f:98d7:: with SMTP id a206mr16449358vke.13.1633867568181; Sun, 10 Oct 2021 05:06:08 -0700 (PDT) MIME-Version: 1.0 References: <20296-1632661753.678317@ipjb.25sX.Whnd> <12742-1633816758.622067@mB95.qJqC.4--_> In-Reply-To: <12742-1633816758.622067@mB95.qJqC.4--_> From: Marlon Richert Date: Sun, 10 Oct 2021 15:05:31 +0300 Message-ID: Subject: Re: Questions about completion matchers To: Oliver Kiddle Cc: Zsh Users Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Seq: 27227 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 Sun, Oct 10, 2021 at 12:59 AM Oliver Kiddle wrote: > > Marlon Richert wrote: > > Thanks, Oliver, for your long and thoughtful response. I'm afraid I don= 't quite > > understand all of it, though. Let me try to explain how I've understood= things, > > but in a way that I find easier to process, and do please correct me wh= ere I'm > > wrong. > > > > The way I've understood it, is that, if $word contains the command line= string > > for which completion is attempted, then each matcher should transform $= word as > > follows: > > That's not what the implementation does in any real sense so I'm not > sure how helpful it is to reframe the regular expressions I gave in zsh > syntax. But the effect is along those basic lines if you view the > "transformed" $word as being a pattern that is matched against each of > the candidate matches in turn to decide which to present as matches. > > I find it helpful as a brief reference but if it doesn't make sense to > you, ignore it. It didn't make sense at first, because I somehow overlooked that you were using regex. I read them as glob patterns. :) But now that I realize that, let me have a second look: On Sun, Sep 26, 2021 at 4:09 PM Oliver Kiddle wrote: > > With matching control, it is often easiest if you view it as converting > what is on the command-line into a regular expression. I haven't probed > the source code to get a precise view of how these are mapped. For my > own purposes, I keep a list but don't trust it in all cases because I've > found contradictory examples and tweaked it more than once, perhaps > making it less accurate in the process. So with the caveat that this > may contain errors, my current list is as follows: > > Not that that starting point is: > [cursor position] =E2=86=92 .* > Then: > 'm:a=3Db' =E2=80=93 a =E2=86=92 b (* doesn't work= on rhs) > 'r:|b=3D*' =E2=80=93 b =E2=86=92 [^b]*b The appearance of [^a] and [^b] in your patterns was a complete surprise to me. I would've expected * to work as * in a glob expression. This is not clear from the docs. Now that I know that the matcher syntax was based on regex, it makes more sense, but I still wouldn't have figured this out intuitively. A clearer explanation about this in the docs would be helpful. Yes, it's mentioned somewhere in the examples, but it should be explained more clearly earlier on. > 'r:a|b=3D*' =E2=80=93 ab =E2=86=92 [^b]*a?b This one looks incorrect to me as it does not match the example in the docs. From that example, it appears to me that it is supposed to work like this: 'r:a|b=3D*' =E2=80=93 b =E2=86=92 [^b]*ab > 'r:a|b=3Dc' - ab =E2=86=92 cb > 'l:a|=3D*' =E2=80=93 a =E2=86=92 [^a]*a > 'l:a|b=3D*' =E2=80=93 ab =E2=86=92 [^a]*ab? Shouldn't these last two result in a[^a]* and ab[^a]*, respectively, since the anchor goes to the left? > 'l:a|b=3Dc' =E2=80=93 ab =E2=86=92 ac > 'b:a=3D*' =E2=80=93 ^a =E2=86=92 .* Oh, but here * does work like a * glob? So, I guess * behaves differently only when anchors are involved? > 'b:a=3Dc' =E2=80=93 ^a =E2=86=92 ^c > 'e:a=3D*' =E2=80=93 a$ =E2=86=92 .* > 'r:a||b=3D*' =E2=80=93 b =E2=86=92 [^a]*ab (only * works o= n rhs, empty a or b has no use) > 'l:a||b=3D*' =E2=80=93 ^a =E2=86=92 a.* (only * on rhs,= empty a no use, b ignored?!) The comments on the last two items sound like bugs to me. Also, 'l:a||b=3D*' should work on just 'a' and not require '^a'. On Sun, Oct 10, 2021 at 12:59 AM Oliver Kiddle wrote: > > The difference between b: and l: with an empty anchor (or e/r) is not > encapsulated by my regular expressions. They only differ in how strict > the anchoring to the start of the match is where another matching > control allowed extra characters to be inserted at the beginning. So, does that mean then that matcher are not evaluated strictly left-to-rig= ht? > The example given when this was added was zsh option completion where > underscores are ignored and a prefix of NO is allowed. About that example, what exactly is the difference between L: and B: that lets B: complete '_NO_f' to '_NO_foo' and 'NONO_f' to 'NONO_f' but not L:? It's not clear from the example, let alone from the description of the matchers. > I took a look at the source code and dug out original -workers posts and > it does seem that the intention for the two anchor || forms was as I > thought. Even as designed I don't think either is ideal for camel case - > the l: form excludes characters from the wrong anchor for that. > The matching code looks a lot like regular expression matching with a > back tracking algorithm. Y02compmatch.ztst contains a lot of examples that could be added to the docs to better explain how the different matchers are intended to be used. It would help to better understand their workings.