diff options
author | Mattias EngdegÄrd <mattiase@acm.org> | 2019-12-13 13:10:58 +0100 |
---|---|---|
committer | Mattias EngdegÄrd <mattiase@acm.org> | 2019-12-13 13:30:14 +0100 |
commit | 82b4e48c590cf2c0448a751e641b0ee7a6a02438 (patch) | |
tree | 55da830604ce9ebe4a5aa626bec285fb688578a3 /test/lisp/emacs-lisp | |
parent | b04086adf649b18cf5309dd43aa638fc7b3cd4a0 (diff) | |
download | emacs-82b4e48c590cf2c0448a751e641b0ee7a6a02438.tar.gz emacs-82b4e48c590cf2c0448a751e641b0ee7a6a02438.tar.bz2 emacs-82b4e48c590cf2c0448a751e641b0ee7a6a02438.zip |
Allow characters and single-char strings in rx charsets
The `not' and `intersection' forms, and `or' inside these forms,
now accept characters and single-character strings as arguments.
Previously, they had to be wrapped in `any' forms.
This does not add expressive power but is a convenience and is easily
understood.
* doc/lispref/searching.texi (Rx Constructs): Amend the documentation.
* etc/NEWS: Announce the change.
* lisp/emacs-lisp/rx.el (rx--charset-p, rx--translate-not)
(rx--charset-intervals, rx): Accept characters and 1-char strings in
more places.
* test/lisp/emacs-lisp/rx-tests.el (rx-not, rx-charset-or)
(rx-def-in-charset-or, rx-intersection): Test the change.
Diffstat (limited to 'test/lisp/emacs-lisp')
-rw-r--r-- | test/lisp/emacs-lisp/rx-tests.el | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/test/lisp/emacs-lisp/rx-tests.el b/test/lisp/emacs-lisp/rx-tests.el index 344f46764c8..a82f1f83645 100644 --- a/test/lisp/emacs-lisp/rx-tests.el +++ b/test/lisp/emacs-lisp/rx-tests.el @@ -272,7 +272,9 @@ (should (equal (rx (not (category tone-mark)) (not (category lao))) "\\C4\\Co")) (should (equal (rx (not (not ascii)) (not (not (not (any "a-z"))))) - "[[:ascii:]][^a-z]"))) + "[[:ascii:]][^a-z]")) + (should (equal (rx (not ?a) (not "b") (not (not "c")) (not (not ?d))) + "[^a][^b]cd"))) (ert-deftest rx-charset-or () (should (equal (rx (or)) @@ -294,13 +296,17 @@ "[a-ru-z]")) (should (equal (rx (or (intersection (any "c-z") (any "a-g")) (not (any "a-k")))) - "[^abh-k]"))) + "[^abh-k]")) + (should (equal (rx (or ?f (any "b-e") "a") (not (or ?x "y" (any "s-w")))) + "[a-f][^s-y]"))) (ert-deftest rx-def-in-charset-or () (rx-let ((a (any "badc")) - (b (| a (any "def")))) - (should (equal (rx (or b (any "q"))) - "[a-fq]"))) + (b (| a (any "def"))) + (c ?a) + (d "b")) + (should (equal (rx (or b (any "q")) (or c d)) + "[a-fq][ab]"))) (rx-let ((diff-| (a b) (not (or (not a) b)))) (should (equal (rx (diff-| (any "a-z") (any "gr"))) "[a-fh-qs-z]")))) @@ -326,7 +332,9 @@ "[e-m]")) (should (equal (rx (intersection (or (any "a-f") (any "f-t")) (any "e-w"))) - "[e-t]"))) + "[e-t]")) + (should (equal (rx (intersection ?m (any "a-z") "m")) + "m"))) (ert-deftest rx-def-in-intersection () (rx-let ((a (any "a-g")) |