Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backreferences in vim-style regexp #1897

Merged
merged 1 commit into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion evil-common.el
Original file line number Diff line number Diff line change
Expand Up @@ -3608,7 +3608,7 @@ transformations, usually `regexp-quote' or `replace-quote'."
(?` . "`") (?^ . "^")
(?$ . "$") (?| . "\\|")))

(defconst evil-regexp-magic "[][(){}<>_dDsSxXoOaAlLuUwWyY.*+?=^$`|nrtb]")
(defconst evil-regexp-magic "[][(){}<>_dDsSxXoOaAlLuUwWyY.*+?=^$`|nrtb0-9]")

(defun evil-transform-vim-style-regexp (regexp)
"Transform vim-style backslash codes to Emacs regexp.
Expand Down
19 changes: 18 additions & 1 deletion evil-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -8319,7 +8319,24 @@ golf h[o]>tel")))
"alpha [b]ravo charlie delta bravo echo"
("/\C-w" [return])
"alpha bravo charlie delta [b]ravo echo")
(custom-set-variables `(evil-want-C-w-delete ,old-val))))))
(custom-set-variables `(evil-want-C-w-delete ,old-val))))
(ert-info ("Can use backreferences with vim-style regexp")
(let ((evil-ex-search-vim-style-regexp t))
(evil-test-buffer
"[a]bacababcacabccadefghij"
;; Very magic
("/\\v(.)(.)(.)\\3\\1/e" [return])
"abacababcacabcc[a]defghij")
(evil-test-buffer
"[a]bacababcacabccadefghij"
;; Default magic
("/\\(.\\)\\(.\\)\\(.\\)\\3\\1/e" [return])
"abacababcacabcc[a]defghij")
(evil-test-buffer
"[a]bacababcac1abcca1defghij"
;; With literal numbers
("/\\(.\\)\\(.\\)\\(.\\)\\3\\11/e" [return])
"abacababcac1abcca[1]defghij")))))

(ert-deftest evil-test-ex-search-offset ()
"Test search offsets."
Expand Down