summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lisp/emacs-lisp/rx.el4
-rw-r--r--test/lisp/emacs-lisp/rx-tests.el4
2 files changed, 6 insertions, 2 deletions
diff --git a/lisp/emacs-lisp/rx.el b/lisp/emacs-lisp/rx.el
index 52a35ffa2a7..6fde27831a0 100644
--- a/lisp/emacs-lisp/rx.el
+++ b/lisp/emacs-lisp/rx.el
@@ -376,7 +376,9 @@ If NEGATED, negate the sense."
(push (cons arg arg) conses))
((and (symbolp arg)
(let ((class (cdr (assq arg rx--char-classes))))
- (and class (push class classes)))))
+ (and class
+ (or (memq class classes)
+ (push class classes))))))
(t (error "Invalid rx `any' argument: %s" arg))))
(let ((items
;; Translate strings and conses into nonoverlapping intervals,
diff --git a/test/lisp/emacs-lisp/rx-tests.el b/test/lisp/emacs-lisp/rx-tests.el
index 4ecc805aead..26e39f8c8ed 100644
--- a/test/lisp/emacs-lisp/rx-tests.el
+++ b/test/lisp/emacs-lisp/rx-tests.el
@@ -128,7 +128,9 @@
(should (equal (rx (any) (not (any)))
"\\`a\\`[^z-a]"))
(should (equal (rx (any "") (not (any "")))
- "\\`a\\`[^z-a]")))
+ "\\`a\\`[^z-a]"))
+ (should (equal (rx (any space ?a digit space))
+ "[a[:space:][:digit:]]")))
(ert-deftest rx-pcase ()
(should (equal (pcase "a 1 2 3 1 1 b"