From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17682 invoked by alias); 11 Jun 2013 17:07:43 -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: 31472 Received: (qmail 28944 invoked from network); 11 Jun 2013 17:07:27 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at closedmail.com does not designate permitted sender hosts) From: Bart Schaefer Message-id: <130611100704.ZM6617@torch.brasslantern.com> Date: Tue, 11 Jun 2013 10:07:03 -0700 In-reply-to: Comments: In reply to Moritz Bunkus "replace-regex widget not replacing semicolons" (Jun 11, 2:49pm) References: X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: Moritz Bunkus , zsh-workers@zsh.org Subject: Re: replace-regex widget not replacing semicolons MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Jun 11, 2:49pm, Moritz Bunkus wrote: } } I'm using replace-regex bound to ALT+r, and it usually works quite } well. Today I noticed that it doesn't replace semicolons, though. It } looks like an off-by-one error when removing the char from the buffer. It works for me with any replacement except those with "&" as the 2nd or later character. I think this is because "&" is a magic character in regexp replacements, meaning a back-reference to the last string that was matched? There's a comment in replace-string-again: # The following horror is so that an & preceded by an even # number of backslashes is active, without stripping backslashes, # while preceded by an odd number of backslashes is inactive, # with one backslash being stripped. A similar logic applies # to \digit. ("an even number of backslashes" includes zero of them). What's happening with "&&" is that on entry to the regexp engine there is no previous match, so "&" means itself. Then the ";" is matched, so now the second "&" means the matched part of the source string, and becomes ";", and you end up with ";" =~ s/;/&&/ --> "&;". Try with &\& or with p&q to see what I mean. That the match pattern is a semicolon doesn't matter.