emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/xr 41474cb 11/13: Accept unknown character categories


From: Mattias Engdegård
Subject: [elpa] externals/xr 41474cb 11/13: Accept unknown character categories
Date: Wed, 13 Feb 2019 04:03:29 -0500 (EST)

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

    Accept unknown character categories
    
    New categories can be defined, so an unknown category code is not
    necessarily an error. Assume the best and use a raw (regexp ...)
    construct.
---
 xr-test.el |  4 +++-
 xr.el      | 10 +++++-----
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/xr-test.el b/xr-test.el
index 9f48d28..97559fb 100644
--- a/xr-test.el
+++ b/xr-test.el
@@ -81,7 +81,7 @@
 (ert-deftest xr-syntax ()
   (should (equal (xr "\\s-\\s \\sw\\sW\\s_\\s.\\s(\\s)\\s\"")
                  '(seq (syntax whitespace) (syntax whitespace) (syntax word)
-                      (syntax word)
+                       (syntax word)
                        (syntax symbol) (syntax punctuation)
                        (syntax open-parenthesis) (syntax close-parenthesis)
                        (syntax string-quote))))
@@ -124,6 +124,8 @@
   (should (equal (xr "\\C2\\C^")
                  '(seq (not (category upper-diacritical-mark))
                        (not (category combining-diacritic)))))
+  (should (equal (xr "\\c%\\C+")
+                 '(seq (regexp "\\c%") (regexp "\\C+"))))
   )
 
 (ert-deftest xr-lazy ()
diff --git a/xr.el b/xr.el
index d77b78c..9d201ad 100644
--- a/xr.el
+++ b/xr.el
@@ -197,10 +197,10 @@
                      (?w . hebrew)                            
                      (?y . cyrillic)                          
                      (?| . can-break)))))
-    (when (not sym)
-      (error "Unknown category code: %c" category-code))
-    (let ((item (list 'category (cdr sym))))
-      (if negated (list 'not item) item))))
+    (if sym
+        (let ((item (list 'category (cdr sym))))
+          (if negated (list 'not item) item))
+      (list 'regexp (format "\\%c%c" (if negated ?C ?c) category-code)))))
 
 (defun xr--char-syntax (negated syntax-code)
   (let ((sym (assq syntax-code
@@ -208,7 +208,7 @@
                      (?\s . whitespace)
                      (?.  . punctuation)
                      (?w  . word)
-                     (?W  . word)      ; undocumented
+                     (?W  . word)       ; undocumented
                      (?_  . symbol)
                      (?\( . open-parenthesis)
                      (?\) . close-parenthesis)



reply via email to

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