[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)
- [elpa] externals/xr updated (7ba1fc6 -> e1c7734), Mattias Engdegård, 2019/02/13
- [elpa] externals/xr 4e2bd17 04/13: Export xr-pp-rx-to-str and fix a typo, Mattias Engdegård, 2019/02/13
- [elpa] externals/xr c2ede95 08/13: Improved errors for bad \s and \c sequences, Mattias Engdegård, 2019/02/13
- [elpa] externals/xr 8425772 01/13: Sync with ELPA: compilation workaround, Mattias Engdegård, 2019/02/13
- [elpa] externals/xr f79d50c 12/13: Add categories L, R, . and SPC, Mattias Engdegård, 2019/02/13
- [elpa] externals/xr 2a1de75 03/13: Correct parsing of group and backref, Mattias Engdegård, 2019/02/13
- [elpa] externals/xr 8d052d6 09/13: Check for errors in \_, Mattias Engdegård, 2019/02/13
- [elpa] externals/xr 37b2bcb 06/13: Merge branch 'master' of https://github.com/mattiase/xr, Mattias Engdegård, 2019/02/13
- [elpa] externals/xr 41474cb 11/13: Accept unknown character categories,
Mattias Engdegård <=
- [elpa] externals/xr e1c7734 13/13: Merge branch 'externals/xr' of elpa.git (no actual change), Mattias Engdegård, 2019/02/13
- [elpa] externals/xr e8ec2d9 07/13: Add reference to the pcre2el package, Mattias Engdegård, 2019/02/13
- [elpa] externals/xr 4bf6043 05/13: Export xr-pp-rx-to-str and fix a typo, Mattias Engdegård, 2019/02/13
- [elpa] externals/xr 8532df8 02/13: Move tests to separate file, Mattias Engdegård, 2019/02/13
- [elpa] externals/xr 0331e00 10/13: Recognise \sW as alias for \sw, Mattias Engdegård, 2019/02/13