From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id 7d892e34 for ; Wed, 18 Sep 2019 02:31:51 +0000 (UTC) Received: (qmail 29820 invoked by alias); 18 Sep 2019 02:31:42 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: List-Unsubscribe: X-Seq: 24250 Received: (qmail 26865 invoked by uid 1010); 18 Sep 2019 02:31:42 -0000 X-Qmail-Scanner-Diagnostics: from mail-pf1-f171.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.101.2/25573. spamassassin: 3.4.2. Clear:RC:0(209.85.210.171):SA:0(-1.8/5.0):. Processed in 1.421487 secs); 18 Sep 2019 02:31:42 -0000 X-Envelope-From: rpigott314@gmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.210.171 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=content-transfer-encoding:date:subject:from:to:message-id; bh=WySwvesatUg9ionLiRin3aInQl04zwx5ZPYhNIOmbkc=; b=nFaZg52y8itD5IyqIizYEu6W0hEGmaN3s7mZetB1X9mwk4QETuxU0ZU7XXU5Ta5fdv FxnaloO46VEVRiYOR96+mVC9TeORF+ebr/2LsqPNFb6gteSP1XUykIJ6vwW/S9Wl1Lg6 nDgolrxJxjzufE0g2QDqZlPZuhE/46ZXxy/oikZ2UmguaWNcYJ9Sn5cpKjLlu+DxHHj5 0ceYXK/7kqcbbZGhrB9KSGjkG6Pkx73djs+WiLxETvbIvuXFZgxFSFzjM8t1j+KU3yjN ZQlwp73Y31jC5gf+KLInV3KResMxYPNMJmfMQJ6WnC8h5X7VSaWkbRg81JH9uDGzxXyW hv+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:content-transfer-encoding:date:subject:from:to :message-id; bh=WySwvesatUg9ionLiRin3aInQl04zwx5ZPYhNIOmbkc=; b=P9Ca1ZVLx2nhKrWY6qDPzzOtMr9/eWVNJtoiSaz/K2uBzSHjXY14Yrmbw+VquFbHrN /XSGJPL6fSVJT0z401UQ+R29FCkuP4/wTWrDnJKgkP3jIE+NXlAvKbIb+izlxFRUkyr0 tldo7iCkATDn2UWBFd5lA/zX12qiTT+atY2P4rVuPmIHrharp1oK54S1qpbv7p8gKZ0c pCBD9CYKKZgpF3d4Hli4LIfIViufnuXH5czBCT6Lb8hrS9BTS06ZoJJW3NKIc8mY/Lkq VdR5zvd/rFZ86hMs1P0LquMSFZ47C+1WNSGz3/G8PkKeS6amYGNSO+ifCZwpMJcZMYW9 ++rA== X-Gm-Message-State: APjAAAWEKjgqc9p+6YOtVYReCh8p2sXCAGWUUyz3uoAl2+Xt3jGEgheX KKpny+OnH2L6RlFRD6mIT7Q0WTs= X-Google-Smtp-Source: APXvYqwm8BbcI51LHKlD4bp3vZo+zT5V1OCETa6mmRbpQkLsGUa4aPEBhuGgPIBN9P5YZvTUbk8Mkw== X-Received: by 2002:a63:1:: with SMTP id 1mr1806893pga.162.1568773866448; Tue, 17 Sep 2019 19:31:06 -0700 (PDT) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Tue, 17 Sep 2019 19:31:04 -0700 Subject: Possible to use _arguments with _regex_arguments? From: "Ronan Pigott" To: Message-Id: X-Qmail-Scanner-2.11: added fake MIME-Version header MIME-Version: 1.0 Hello, I've written a number of zsh completions recently and I find that generally there are two patterns that work well, with _arguments using ->state to dispatch completions and _regex_arguments to build a regex state machine. Often I find that I'd like to use both _arguments and _regex_arguments together, using _arguments to parse the opt_args and _regex_arguments to handle the rest. I think it would have some advantages over building the whole completion in _regex_arguments. _arguments already closely resembles the behavior of getopt, consuming arguments it recognizes and leaving the remainder in $line for dispatched functions to consider. It also easily supports behavior where it ignores flags following a '--' argument, which is not trivial to replicate with _regex_arguments. Ideally, I think it would be possible to use _arguments to define the flagged arguments I want to check and keep their values in opt_args, but use a _regex_arguments function as an action for _arguments acting on $line, like so: ``` _regex_arguments _myfunc ... _arguments -S -s \ {-o+,--option}'[An option]:tag:(some values)' '*:positional arguments:_myfunc' ``` However, in the above case, if _myfunc was not carefully crafted to ignore '--option' it will fail to match and provide no completions because _myfunc operates exclusively on $words. Is it possible to use _regex_arguments functions on anything else, or in any other context? One thing I thought to try was set '{words=3D("$line[@]"); _myfunc}' for the action, but it did not seem to work. If it cannot be done, is there another way that I can transform the line to be completed before running (or re-running) the completion to make this idea possible?