zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Moritz Bunkus <moritz@bunkus.org>, zsh-workers@zsh.org
Subject: Re: replace-regex widget not replacing semicolons
Date: Tue, 11 Jun 2013 10:07:03 -0700	[thread overview]
Message-ID: <130611100704.ZM6617@torch.brasslantern.com> (raw)
In-Reply-To: <CANPayMR2TPcxOz-GY6kQYuXongGMy5W_d255y7JZn2_Z+dg3CQ@mail.gmail.com>

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.


  reply	other threads:[~2013-06-11 17:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-11 12:49 Moritz Bunkus
2013-06-11 17:07 ` Bart Schaefer [this message]
2013-06-12  6:46   ` Moritz Bunkus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=130611100704.ZM6617@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=moritz@bunkus.org \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).