unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Nicholas Drozd <nicholasdrozd@gmail.com>
To: Juri Linkov <juri@linkov.net>
Cc: Lars Ingebrigtsen <larsi@gnus.org>, 45973@debbugs.gnu.org
Subject: bug#45973: replace-regexp lisp replacement bug
Date: Tue, 19 Jan 2021 16:36:20 -0600	[thread overview]
Message-ID: <CABAiW0ov1O3YpXJav09n-qcBmQX2hR+E57HqMyk7h5hxY15NGw@mail.gmail.com> (raw)
In-Reply-To: <87v9bsaj4t.fsf@mail.linkov.net>

[-- Attachment #1: Type: text/plain, Size: 79 bytes --]

Thanks for the quick turnaround. I've included a patch to add a test for this.

[-- Attachment #2: 0001-test-lisp-replace-tests.el-Add-nested-match-group-te.patch --]
[-- Type: text/x-patch, Size: 1209 bytes --]

From d7bed718a5a88cc834456ac8d2e39ffc4f07e292 Mon Sep 17 00:00:00 2001
From: Nick Drozd <nicholasdrozd@gmail.com>
Date: Tue, 19 Jan 2021 16:26:02 -0600
Subject: [PATCH] * test/lisp/replace-tests.el: Add nested match group test

---
 test/lisp/replace-tests.el | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/test/lisp/replace-tests.el b/test/lisp/replace-tests.el
index 8c2682a1f1..2db570c97d 100644
--- a/test/lisp/replace-tests.el
+++ b/test/lisp/replace-tests.el
@@ -587,5 +587,18 @@ occur-highlight-occurrence
                               (get-text-property (point) 'occur-target))
           (should (funcall check-overlays has-overlay)))))))
 
+(ert-deftest replace-regexp-bug45973 ()
+  "Test for https://debbugs.gnu.org/45973 ."
+  (let ((before "1RB 1LC 1RC 1RB 1RD 0LE 1LA 1LD 1RH 0LA")
+        (after  "1LB 1RC 1LC 1LB 1LD 0RE 1RA 1RD 1LH 0RA"))
+    (with-temp-buffer
+      (insert before)
+      (goto-char (point-min))
+      (replace-regexp
+       "\\(\\(L\\)\\|\\(R\\)\\)"
+       '(replace-eval-replacement
+         replace-quote
+         (if (match-string 2) "R" "L")))
+      (should (equal (buffer-string) after)))))
 
 ;;; replace-tests.el ends here
-- 
2.17.1


  reply	other threads:[~2021-01-19 22:36 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-19  0:15 bug#45973: replace-regexp lisp replacement bug Nicholas Drozd
2021-01-19  3:44 ` Lars Ingebrigtsen
2021-01-19 18:14   ` Juri Linkov
2021-01-19 22:36     ` Nicholas Drozd [this message]
2021-01-20  1:46       ` Lars Ingebrigtsen

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=CABAiW0ov1O3YpXJav09n-qcBmQX2hR+E57HqMyk7h5hxY15NGw@mail.gmail.com \
    --to=nicholasdrozd@gmail.com \
    --cc=45973@debbugs.gnu.org \
    --cc=juri@linkov.net \
    --cc=larsi@gnus.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.savannah.gnu.org/cgit/emacs.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).