From: "Andreas Röhler" <andreas.roehler@easy-emacs.de>
To: Andreas Schwab <schwab@linux-m68k.org>
Cc: 12622@debbugs.gnu.org
Subject: bug#12622: replace-regexp-in-string
Date: Thu, 11 Oct 2012 18:38:00 +0200 [thread overview]
Message-ID: <5076F5E8.8090205@easy-emacs.de> (raw)
In-Reply-To: <m2d30pkr0s.fsf@igel.home>
Am 11.10.2012 16:44, schrieb Andreas Schwab:
> Andreas Röhler <andreas.roehler@easy-emacs.de> writes:
>
>> Also would expect a respective form working with replace-regexp-in-string
>>
>> (setq mystring "[.A foobar] [.B baz]")
>> (replace-regexp-in-string "\\_<\\w+\\_>" (concat "\\\\" (match-string-no-properties 0) ) mystring)
>>
>> but it fails.
>
> Fails in which way? What do you expect, and what do you get?
>
>> When commenting "(match-string 0 str)" as follows it subr.el it works
>>
>> (setq matches
>> (cons (replace-match (if (stringp rep)
>> rep
>> (funcall rep
>> ;; (match-string 0 str)
>> ))
>> fixedcase literal str subexp)
>>
>> Which has some plausibility: when receiving a user-specified function, there must not be that argument.
>
> Why? That's what the doc string documents.
>
> Andreas.
>
(setq mystring "[.A foobar] [.B baz]")
;; works nice in buffer
(while (re-search-forward "\\_<\\w+\\_>" nil t 1)
(replace-match (concat "\\\\\\\\" (match-string-no-properties 0) )))
==>
[.A \\foobar] [.B \\baz]
has unpredictable results
(setq mystring "[.A foobar] [.B baz]")
(replace-regexp-in-string "\\_<\\w+\\_>" (concat "\\\\" (match-string-no-properties 0)) mystring) ==>
"[.A \\ext in that fi] [.B \\ext in that fi]"
for example,
Docstring says:
"If it is a function, it is called with the actual text of each
match, and its value is used as the replacement text."
Which is not the case AFAIS.
next prev parent reply other threads:[~2012-10-11 16:38 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-11 14:17 bug#12622: replace-regexp-in-string Andreas Röhler
2012-10-11 14:44 ` Andreas Schwab
2012-10-11 16:38 ` Andreas Röhler [this message]
2012-10-11 16:52 ` Andreas Schwab
2012-10-12 6:32 ` Andreas Röhler
2012-10-12 8:14 ` Andreas Schwab
2012-10-12 14:22 ` Stefan Monnier
2012-10-12 16:07 ` Andreas Röhler
2012-10-12 18:12 ` Stefan Monnier
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=5076F5E8.8090205@easy-emacs.de \
--to=andreas.roehler@easy-emacs.de \
--cc=12622@debbugs.gnu.org \
--cc=schwab@linux-m68k.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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.