branch: externals/xr commit 74b5287e3cf2f73f3fe34dffb91f3671e56b94a3 Author: Mattias Engdegård <matti...@acm.org> Commit: Mattias Engdegård <matti...@acm.org>
Turn negative empty sets into anything [^z-a] was found in the wild (auctex), apparently on purpose. The correct rx translation should be `anything'. --- xr-test.el | 2 ++ xr.el | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/xr-test.el b/xr-test.el index 7beee0a..8dc2453 100644 --- a/xr-test.el +++ b/xr-test.el @@ -174,6 +174,8 @@ '(seq (not (any "\\o")) (any "A-\\") (any "A-a")))) (should (equal (xr "[^A-FFGI-LI-Mb-da-eg-ki-ns-tz-v]") '(not (any "A-FI-Ma-eg-ns-t" "G")))) + (should (equal (xr "[z-a][^z-a]") + '(seq (any) anything))) ) (ert-deftest xr-empty () diff --git a/xr.el b/xr.el index 3b804ad..03b2110 100644 --- a/xr.el +++ b/xr.el @@ -190,7 +190,16 @@ ranges))) sorted) + ;; Note that we return (any) for non-negated empty sets, + ;; such as [z-a]. (any) is not accepted by rx but at least we + ;; are not hiding potential bugs from the user. (cond + ;; Negated empty set, like [^z-a]: anything. + ((and negated + (null chars) + (null ranges) + (null classes)) + 'anything) ;; Non-negated single-char set, like [$]: make a string. ((and (= (length chars) 1) (not negated)