From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26479 invoked by alias); 4 Jun 2016 05:58:26 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 38597 Received: (qmail 1789 invoked from network); 4 Jun 2016 05:58:24 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:in-reply-to:comments:references:to:subject :mime-version; bh=ZaK+pvnU4V1ZKriDgtZ3h21U0hNFeCUUN2CxYxqMxOY=; b=eaiS5z73pf5LMe7AyTWq/2Fem08g6rW8yPBqU/fa5a6Pv/9VuCuDSTSy0F8AqgCwaW opY6FRvzzXm6aH1NVwetD8xO4drI5+ixaC7u90hUtqnyPbizyXzXjd+MycIH7DSbZPjN S+qGQdzpXGQi7vuPDpS435rBWCb858gm5HjHVjqo2XEjLQhgQ6B6CUDzlFzGvghYJTj9 xLpwD5OSclgENYlq2CxAPfAq5Q2xAYo3qcRRFi7dMydwtJzkt+iVwHdmjpdA/Sop81xh vwnwK6N37jBjCkrB3bH/cKMIevwkMHg+QkK5yw+Y6v9ezAkjfeQ1P2Hc7+EI2vPjVAuC FnVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:message-id:date:in-reply-to:comments :references:to:subject:mime-version; bh=ZaK+pvnU4V1ZKriDgtZ3h21U0hNFeCUUN2CxYxqMxOY=; b=T5tnCTvRg8ic+YLmlxfB2NN8H/SVkWLy8AEI9eZW+akQ5pOsObD5QBvuAcnr3sZzCs cOEzxHk/SR1CHO49BHFuvuhN1qV1nrnNktE/lzBWm5FzPY1qWbIJ1LyKnbdt3MB4berf MY0r3caN9rSu/+jxzFu26QtfaTgCwSoy1yNtjeOILE1wfnfPyr2uXszClHx0tYZJ2abo ywvhEwLVzll9M/kFxOMmOXnSabGn5ffjbpiAJhnyJEmlOBYT41TX8dqo398VSN6Gd/6m JxqEUkXCrGSY5YxHWKsxJ542sWiG9IltPH2Xhe7AUYjRqjgQt28OSw1CfwpjeVHvqZ7m NmsA== X-Gm-Message-State: ALyK8tJ6BTkMD5K6qgg4NmkUYyqtGtPOK0kiBs/V3+Qude5rZtT1gz9ZZ8d5BokY+G46aQ== X-Received: by 10.98.68.203 with SMTP id m72mr10586149pfi.135.1465019900932; Fri, 03 Jun 2016 22:58:20 -0700 (PDT) From: Bart Schaefer Message-Id: <160603225821.ZM25900@torch.brasslantern.com> Date: Fri, 3 Jun 2016 22:58:21 -0700 In-Reply-To: Comments: In reply to Sebastian Gniazdowski "Re: MBEGIN, MEND in #m when pattern has "|"" (Jun 3, 6:47am) References: <160602151123.ZM21157@torch.brasslantern.com> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: Zsh hackers list Subject: Re: MBEGIN, MEND in #m when pattern has "|" MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Jun 3, 6:47am, Sebastian Gniazdowski wrote: } Subject: Re: MBEGIN, MEND in #m when pattern has "|" } } On 3 June 2016 at 00:11, Bart Schaefer wrote: } > MATCH MBEGIN and MEND are set only if there is a single possible match } > (more precisely, when the string can be matched with only a combination } > of strcmp() and simple wildcards). In //pat/repl/, there are multiple } > possible match positions; which begin and end do you want? } } The ones that are substituted, i.e. if #m knows that it will replace } "vim", it should give indexes for that substring, and if it knows it } will replace "s", then should give indexes for it, etc. On closer inspection, your problem isn't what I thought it was. Note this bit of the doc: m Set references to the match data for the entire string matched; this is similar to backreferencing and does not work in filename generation. The flag must be in effect at the end of the pattern, i.e. not local to a group. When you do (#mi)this|that The #m ends at the "|", and so is not "in effect at the end of the pattern" which is after "that". So if you change your expression to be one of harray=( "${(f)${text//(#mi)(${~colsearch_pattern})/|$(( MBEGIN - 1 )) $(( MEND )) fg=red,bold|$nl}%$nl*}" ) [added parens around the alternates] or harray=( "${(f)${text//(#i)${~colsearch_pattern}(#m)/|$(( MBEGIN - 1 )) $(( MEND )) fg=red,bold|$nl}%$nl*}" ) [moved (#m) to the end] then $MBEGIN et al. work as you desire. I suspect you actually want the first with the parens because otherwise the (#i) also ends at the "|".