Commit d4241959 authored by Mattias Engdegård's avatar Mattias Engdegård

Fix rx charset generation

* lisp/emacs-lisp/rx.el (rx--charset-p): Don't overquote.
(rx--generate-alt): Generate '.' for negated newline.
* test/lisp/emacs-lisp/rx-tests.el (rx-any, rx-charset-or): Test.
parent 9908b5a6
Pipeline #4894 failed with stage
in 54 minutes and 52 seconds
......@@ -305,7 +305,7 @@ Return (REGEXP . PRECEDENCE)."
"Whether FORM looks like a charset, only consisting of character intervals
and set operations."
(or (and (consp form)
(or (and (memq (car form) '(any 'in 'char))
(or (and (memq (car form) '(any in char))
(rx--every (lambda (x) (not (symbolp x))) (cdr form)))
(and (memq (car form) '(not or | intersection))
(rx--every #'rx--charset-p (cdr form)))))
......@@ -450,6 +450,10 @@ classes."
(not negated))
(cons (list (regexp-quote (char-to-string (caar items))))
;; Negated newline.
((and (equal items '((?\n . ?\n)))
(rx--translate-symbol 'nonl))
;; At least one character or class, possibly negated.
......@@ -130,7 +130,10 @@
(should (equal (rx (any "") (not (any "")))
(should (equal (rx (any space ?a digit space))
(should (equal (rx (not "\n") (not ?\n) (not (any "\n")) (not-char ?\n)
(| (not (in "a\n")) (not (char ?\n (?b . ?b)))))
(ert-deftest rx-pcase ()
(should (equal (pcase "a 1 2 3 1 1 b"
......@@ -298,7 +301,11 @@
(not (any "a-k"))))
(should (equal (rx (or ?f (any "b-e") "a") (not (or ?x "y" (any "s-w"))))
(should (equal (rx (not (or (in "abc") (char "bcd"))))
(should (equal (rx (or (not (in "abc")) (not (char "bcd"))))
(ert-deftest rx-def-in-charset-or ()
(rx-let ((a (any "badc"))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment