diff --git a/evil-common.el b/evil-common.el index fd259d6c..4397a9c3 100644 --- a/evil-common.el +++ b/evil-common.el @@ -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. diff --git a/evil-tests.el b/evil-tests.el index 89bc4977..dcf8fce8 100644 --- a/evil-tests.el +++ b/evil-tests.el @@ -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."