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 5386 invoked from network); 19 Oct 2021 10:24:20 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 19 Oct 2021 10:24:20 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1634639060; b=kQGQWTg4BHNQr49KaPpJQKd4p8kpp7TlcriV8gUXTAyHkOyV0oR4nCue0NWt62qmc/yO+gn1bz Y9QJwTk5z0H3o8DUS7WLDtlhvydkkEYYxhYJbc0f2V0ITkRmlHtO2l6lM+1385/5g4gk5taxXC N6QVvt7vGdQoxbBQYZHzdmm0QosvcVgJljr9TBNY2fwWkNFstZX0WHz9wFCYpK2W48mGKvJ1oB bsM/28FnXTOY2cMLaR/ojOwRcsNBZaPkTHFyf7NFrQ0+3DSkCjk9ltR0y/xy0dF9Awctc8+lPi Q5/6xJG+9Ny1ltcuWurB2T8TBBfLnS327Vrbrgprhcu4Qw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (snd00005-bg.im.kddi.ne.jp) smtp.remote-ip=27.86.113.5; dmarc=none header.from=kba.biglobe.ne.jp; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1634639060; bh=jgOFxrPHG27scp44CMCiQtbz/LWZ5lml8g4NZtB90b8=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:To:Date:Message-ID:Subject:MIME-Version: Content-Transfer-Encoding:Content-Type:From:DKIM-Signature; b=l7p1stneULRAS/xE/NsJcyYdrMO2d5TDf7HEnBBiWj3VGXHuyXbD31kgtlc6Qkf0yAqNRMjst3 tWH39/EsIwq96uqm2rLYPrg0IvbV3h7U8WgNr8P1R8AxLZe1mVLeesQQb+ghvXX6gt7Qmn2l0z ssGgW+NhWTKnmMSi4gBkH8Z2WmidarIiubUdqcjAnhvA8VFFhnQzU+GKs8uS19kQb6H+Pkr8O7 oWaBp+yf3uI/gOYUEXNHDwl5wyXMS227OCYLiwDyUojagEPQmsARm6LwJ5U/9roTSBvRAsPtv/ dKECcpbK7I5vUb9IWqeo/E+gK5Pq6OLV+ZHI6yqjF9eQtw==; 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:To:Date:Message-Id:Subject: Mime-Version:Content-Transfer-Encoding:Content-Type:From:Reply-To:Cc: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References; bh=sxSBxVZJBH2fhVE3C+RaQfH3fEXymE8ziQpdxd4bC+U=; b=sRQmOp2W+oFTtHMAHKE79cbWDQ S6z22NNocUWftvaBeerRMVXyQvqqnMwOoWvbpxona71Tl9aNYyDY1PzF6m9Anw6UlygZesBQJdu/T fniSLLAiUHjCcDWcKgizFvypBQYXiyjE8bLg1ugcwsvGuyNNmzEikclVxoFiBRVBSrQWtNSxnGvO1 Fwv6L4B3Pq66AC8BlFKr1yMvMZPUoI79uzxBhsJB8c5OmH/CboP227iiGe+Cj2SRtR+dZoAYa9TgV Ix/SHAHnC9v6C4Pd9vPKKjJXBYrGp1rut2l+7hwhdpU5+1z3xPOYjfswpdK7kpSEJjy7PUQ/j+n70 KcCEU76w==; Received: from authenticated user by zero.zsh.org with local id 1mcmI6-0001r8-Pd; Tue, 19 Oct 2021 10:24:18 +0000 Authentication-Results: zsh.org; iprev=pass (snd00005-bg.im.kddi.ne.jp) smtp.remote-ip=27.86.113.5; dmarc=none header.from=kba.biglobe.ne.jp; arc=none Received: from snd00005-bg.im.kddi.ne.jp ([27.86.113.5]:42659 helo=dfmta0017.biglobe.ne.jp) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1mcmHO-0001Yk-0P; Tue, 19 Oct 2021 10:23:36 +0000 Received: from mail.biglobe.ne.jp by omta0017.biglobe.ne.jp with ESMTP id <20211019102326317.HAEA.113758.mail.biglobe.ne.jp@biglobe.ne.jp> for ; Tue, 19 Oct 2021 19:23:26 +0900 From: Jun T Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.21\)) Subject: [PATCH] fix option -A of _arguments Message-Id: <5DB568C4-53A2-40C2-88E1-0EAB24C210AA@kba.biglobe.ne.jp> Date: Tue, 19 Oct 2021 19:23:25 +0900 To: zsh-workers@zsh.org X-Mailer: Apple Mail (2.3445.104.21) X-Biglobe-Sender: takimoto-j@kba.biglobe.ne.jp X-Seq: 49496 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: Consider the following example: % _cmd () { _arguments -A '-*' : -a -b '*: :_file' } % compdef _cmd cmd cmd -x - No match for: `file' But zshcompsys(1) says: -A pat Do not complete options after the first non-option argument on the = line. pat is a pattern matching all strings which are not to be taken as = arguments. For example, to make _arguments stop completing options after the = first normal argument, but ignoring all strings starting with a hyphen even = if they are not described by one of the optspecs, the form is `-A "-*"'. In the example above, -x should not be taken as a normal argument since = it matches the pattern '-*' (although it is not in the optspecs), and the options -a and -b should still be offered here (if I understand the = document correctly). With the patch below, ca_inactive() is called only if -A pat is given, and the word under inspection ('-x' in the example above) does not match the pat so it can be considered as a normal argument, and the word ('-x') is before the cursor. diff --git a/Src/Zle/computil.c b/Src/Zle/computil.c index e08788e89..9d9a09543 100644 --- a/Src/Zle/computil.c +++ b/Src/Zle/computil.c @@ -1995,7 +1995,7 @@ ca_parse_line(Cadef d, Cadef all, int multi, int = first) Caopt ptr, wasopt =3D NULL, dopt; struct castate state; char *line, *oline, *pe, **argxor =3D NULL; - int cur, doff, argend, arglast; + int cur, doff, argend, arglast, notmatch; Patprog endpat =3D NULL, napat =3D NULL; LinkList sopts =3D NULL; #if 0 @@ -2236,9 +2236,10 @@ ca_parse_line(Cadef d, Cadef all, int multi, int = first) && (ca_foreign_opt(d, all, line))) return 1; else if (state.arg && - (!napat || cur <=3D compcurrent || !pattry(napat, = line))) { + (!napat || (notmatch =3D !pattry(napat, line)) || + cur <=3D compcurrent)) { /* Otherwise it's a normal argument. */ - if (napat && cur <=3D compcurrent) + if (napat && notmatch && cur <=3D compcurrent) ca_inactive(d, NULL, cur + 1, 1); =20 arglast =3D 1;