[Top][All Lists]

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

[elpa] externals/xr a948847 3/5: Don't complain about [z-a]

From: Mattias Engdegård
Subject: [elpa] externals/xr a948847 3/5: Don't complain about [z-a]
Date: Thu, 21 Mar 2019 09:23:02 -0400 (EDT)

branch: externals/xr
commit a948847b2f527a0d19a9db3f5348516304786f32
Author: Mattias Engdegård <address@hidden>
Commit: Mattias Engdegård <address@hidden>

    Don't complain about [z-a]
    z-a is much more likely to be an empty range on purpose than a mistake.
    In particular, [^z-a] is occasionally seen as a (arguably misguided)
    expression for matching any character.
 xr-test.el | 2 ++
 xr.el      | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/xr-test.el b/xr-test.el
index 17b0b09..fd36db2 100644
--- a/xr-test.el
+++ b/xr-test.el
@@ -342,6 +342,8 @@
   (should (equal (xr-lint "[]-Qa-fz-t]")
                  '((1 . "Reversed range `]-Q' matches nothing")
                    (7 . "Reversed range `z-t' matches nothing"))))
+  (should (equal (xr-lint "[z-a][^z-a]")
+                 nil))
   (should (equal (xr-lint "[^A-FFGI-LI-Mb-da-eg-ki-ns-t33-7]")
                  '((5  . "Character `F' included in range `A-F'")
                    (10 . "Ranges `I-L' and `I-M' overlap")
diff --git a/xr.el b/xr.el
index 55465e9..e76b150 100644
--- a/xr.el
+++ b/xr.el
@@ -126,6 +126,8 @@
            ((<= start end)
             (push (vector start end (point)) intervals))
+           ;; It's unlikely that anyone writes z-a by mistake; don't complain.
+           ((and (eq start ?z) (eq end ?a)))
             (xr--report warnings (point)
                         (format "Reversed range `%s' matches nothing"

reply via email to

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