[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/evil d28206ccff: Disable vim-style-regexp conversions of a
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/evil d28206ccff: Disable vim-style-regexp conversions of already converted patterns (#1827) |
Date: |
Tue, 19 Sep 2023 18:59:33 -0400 (EDT) |
branch: elpa/evil
commit d28206ccff74bc07ba335b8ff77805564f6928d7
Author: Tom Dalziel <33435574+tomdl89@users.noreply.github.com>
Commit: GitHub <noreply@github.com>
Disable vim-style-regexp conversions of already converted patterns (#1827)
* (Failing) test for `&` with very-magic vim-style backreferences
* Disable vim-style-regexp conversions of already converted patterns
---
evil-search.el | 10 ++++++++--
evil-tests.el | 15 ++++++++++++++-
2 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/evil-search.el b/evil-search.el
index d4f870bcb6..9f283a29c9 100644
--- a/evil-search.el
+++ b/evil-search.el
@@ -1158,7 +1158,7 @@ special situations like empty patterns or repetition of
previous
substitution commands. If IMPLICIT-R is non-nil, then the \"r\" flag
is assumed, i.e. in case of an empty pattern the last search pattern
is used. It is meant for :substitute commands with arguments."
- (let (pattern replacement flags)
+ (let (pattern replacement flags using-prev-pattern)
(cond
((or (string= string "") (string-match-p "\\`[a-zA-Z]" string))
;; No pattern, since it starts with a letter which cannot be a
@@ -1191,8 +1191,10 @@ is used. It is meant for :substitute commands with
arguments."
(if (eq evil-search-module 'evil-search)
(if (and evil-ex-last-was-search (memq ?r flags))
(and evil-ex-search-pattern
+ (setq using-prev-pattern t)
(evil-ex-pattern-regex evil-ex-search-pattern))
(and evil-ex-substitute-pattern
+ (setq using-prev-pattern t)
(evil-ex-pattern-regex evil-ex-substitute-pattern)))
(if (eq case-fold-search t)
isearch-string
@@ -1200,7 +1202,11 @@ is used. It is meant for :substitute commands with
arguments."
flags (remq ?r flags)))
;; generate pattern
(when pattern
- (setq pattern (evil-ex-make-substitute-pattern pattern flags)))
+ ;; Disable vim-style regexp conversion if using a previous pattern,
because
+ ;; this conversion will already have been done before storing it
+ (let ((evil-ex-search-vim-style-regexp (and
evil-ex-search-vim-style-regexp
+ (not using-prev-pattern))))
+ (setq pattern (evil-ex-make-substitute-pattern pattern flags))))
(list pattern replacement flags)))
(defun evil-ex-nohighlight ()
diff --git a/evil-tests.el b/evil-tests.el
index 2e03df930b..cd032dfcc0 100644
--- a/evil-tests.el
+++ b/evil-tests.el
@@ -7997,7 +7997,20 @@ golf h[o]>tel")))
(":s/foo/AAA/g" [return])
"[x]xx AAA bar AAA bar AAA bar\nxxx foo bar foo bar foo bar"
("g&")
- "xxx AAA bar AAA bar AAA bar\n[x]xx AAA bar AAA bar AAA bar")))
+ "xxx AAA bar AAA bar AAA bar\n[x]xx AAA bar AAA bar AAA bar"))
+ (ert-info ("Repeat magic multiple times")
+ (let ((evil-magic 'very-magic)
+ (evil-ex-search-vim-style-regexp t))
+ (evil-test-buffer
+ "[b]ravo, alpha\ndelta, charlie\nfoxtrot, echo\nhotel, golf"
+ (":s/(.*), (.*)/\\2 \\1" [return])
+ "alpha bravo\ndelta, charlie\nfoxtrot, echo\nhotel, golf"
+ ("j&")
+ "alpha bravo\ncharlie delta\nfoxtrot, echo\nhotel, golf"
+ ("j&")
+ "alpha bravo\ncharlie delta\necho foxtrot\nhotel, golf"
+ ("j&")
+ "alpha bravo\ncharlie delta\necho foxtrot\ngolf hotel"))))
(ert-deftest evil-test-ex-regex-without-case ()
"Test `evil-ex-regex-without-case'"
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [nongnu] elpa/evil d28206ccff: Disable vim-style-regexp conversions of already converted patterns (#1827),
ELPA Syncer <=