Skip to content

Commit

Permalink
Backreferences in vim-style regexp
Browse files Browse the repository at this point in the history
  • Loading branch information
tomdl89 committed May 6, 2024
1 parent 76667a1 commit a8b28f5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
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

0 comments on commit a8b28f5

Please sign in to comment.