[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#65536: 30.0.50; replace-regexp-in-string documentation does not ment
From: |
Jens Schmidt |
Subject: |
bug#65536: 30.0.50; replace-regexp-in-string documentation does not mention it saves match data |
Date: |
Fri, 25 Aug 2023 17:26:03 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.14.0 |
On 2023-08-25 16:18, Eli Zaretskii wrote:
>> Date: Fri, 25 Aug 2023 15:16:29 +0200
>> From: Jens Schmidt via "Bug reports for GNU Emacs,
>> the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
>> Maybe this should be explicitly documented in its doc string and/or
>> the Emacs Lisp manual ((elisp) Search and Replace) so that users of
>> the function can rely on that fact?
>
> Is it important to promise never to clobber match-data in this
> function?
Not sure whether the following is convincing enough ...
- I came across this question in the following scenario:
(match-fat-regexp with a lot of subres, one of which matches quoted
chars: "\\(?5:\\(?:[[:alnum:]_]+\\|\\\\.\\)+\\)")
(let ((a (match-string 1 input))
;; unquote quoted chars
(b (replace-regexp-in-string
"\\\\\\(.\\)" "\\1"
(match-string 5 input)
t nil))
(c (match-string 7 input)))
...)
So for that and similar scenarios it would be helpful.
- And since `replace-regexp-in-string' contains that `save-match-data'
for a long time already (at least since Emacs 23) I guess that a lot
of authors have been relying on that fact, either consciously, after
having peeked into the function, or unconsciously.
- If it helps, I could provide a patch ...
- bug#65536: 30.0.50; replace-regexp-in-string documentation does not mention it saves match data, Jens Schmidt, 2023/08/25
- bug#65536: 30.0.50; replace-regexp-in-string documentation does not mention it saves match data, Eli Zaretskii, 2023/08/25
- bug#65536: 30.0.50; replace-regexp-in-string documentation does not mention it saves match data,
Jens Schmidt <=
- bug#65536: 30.0.50; replace-regexp-in-string documentation does not mention it saves match data, Jens Schmidt, 2023/08/25
- bug#65536: 30.0.50; replace-regexp-in-string documentation does not mention it saves match data, Eli Zaretskii, 2023/08/26
- bug#65536: 30.0.50; replace-regexp-in-string documentation does not mention it saves match data, Ihor Radchenko, 2023/08/26
- bug#65536: 30.0.50; replace-regexp-in-string documentation does not mention it saves match data, Stefan Kangas, 2023/08/26
- bug#65536: 30.0.50; replace-regexp-in-string documentation does not mention it saves match data, Eli Zaretskii, 2023/08/26