emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

emacs-27 d424195: Fix rx charset generation


From: Mattias Engdegård
Subject: emacs-27 d424195: Fix rx charset generation
Date: Sat, 29 Feb 2020 04:17:15 -0500 (EST)

branch: emacs-27
commit d42419590563964fd61b35dea7738e77c0f90cba
Author: Mattias Engdegård <address@hidden>
Commit: Mattias Engdegård <address@hidden>

    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.
---
 lisp/emacs-lisp/rx.el            |  6 +++++-
 test/lisp/emacs-lisp/rx-tests.el | 11 +++++++++--
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/lisp/emacs-lisp/rx.el b/lisp/emacs-lisp/rx.el
index b4cab57..1ee5e82 100644
--- a/lisp/emacs-lisp/rx.el
+++ b/lisp/emacs-lisp/rx.el
@@ -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))))
             t))
+     ;; Negated newline.
+     ((and (equal items '((?\n . ?\n)))
+           negated)
+      (rx--translate-symbol 'nonl))
      ;; At least one character or class, possibly negated.
      (t
       (cons
diff --git a/test/lisp/emacs-lisp/rx-tests.el b/test/lisp/emacs-lisp/rx-tests.el
index a6c172a..2e34d65 100644
--- a/test/lisp/emacs-lisp/rx-tests.el
+++ b/test/lisp/emacs-lisp/rx-tests.el
@@ -130,7 +130,10 @@
   (should (equal (rx (any "") (not (any "")))
                  "\\`a\\`[^z-a]"))
   (should (equal (rx (any space ?a digit space))
-                 "[a[:space:][:digit:]]")))
+                 "[a[:space:][:digit:]]"))
+  (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"))))
                  "[^abh-k]"))
   (should (equal (rx (or ?f (any "b-e") "a") (not (or ?x "y" (any "s-w"))))
-                 "[a-f][^s-y]")))
+                 "[a-f][^s-y]"))
+  (should (equal (rx (not (or (in "abc") (char "bcd"))))
+                 "[^a-d]"))
+  (should (equal (rx (or (not (in "abc")) (not (char "bcd"))))
+                 "[^bc]")))
 
 (ert-deftest rx-def-in-charset-or ()
   (rx-let ((a (any "badc"))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]