[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/xr 6f0cb49 1/5: Generate (category CHAR) for unknown ca
From: |
Mattias Engdegård |
Subject: |
[elpa] externals/xr 6f0cb49 1/5: Generate (category CHAR) for unknown categories |
Date: |
Sun, 4 Aug 2019 13:42:01 -0400 (EDT) |
branch: externals/xr
commit 6f0cb49d19310acfae2c4c8f07f526ef7daf36d2
Author: Mattias Engdegård <address@hidden>
Commit: Mattias Engdegård <address@hidden>
Generate (category CHAR) for unknown categories
This is accepted by rx (and ry), and is more readable than
(regexp "\\cCHAR").
---
xr-test.el | 2 +-
xr.el | 94 ++++++++++++++++++++++++++++++--------------------------------
2 files changed, 47 insertions(+), 49 deletions(-)
diff --git a/xr-test.el b/xr-test.el
index a3219dd..0fceb16 100644
--- a/xr-test.el
+++ b/xr-test.el
@@ -132,7 +132,7 @@
(not (category base)) (category strong-left-to-right)
(not (category space-for-indent)))))
(should (equal (xr "\\c%\\C+")
- '(seq (regexp "\\c%") (regexp "\\C+"))))
+ '(seq (category ?%) (not (category ?+)))))
(should-error (xr "\\c"))
(should-error (xr "\\C"))
)
diff --git a/xr.el b/xr.el
index 018b888..cfaa06e 100644
--- a/xr.el
+++ b/xr.el
@@ -323,54 +323,52 @@ adjacent strings."
result))
(defun xr--char-category (negated category-code)
- (let ((sym (assq category-code
- '((?\s . space-for-indent)
- (?. . base)
- (?0 . consonant)
- (?1 . base-vowel)
- (?2 . upper-diacritical-mark)
- (?3 . lower-diacritical-mark)
- (?4 . tone-mark)
- (?5 . symbol)
- (?6 . digit)
- (?7 . vowel-modifying-diacritical-mark)
- (?8 . vowel-sign)
- (?9 . semivowel-lower)
- (?< . not-at-end-of-line)
- (?> . not-at-beginning-of-line)
- (?A . alpha-numeric-two-byte)
- (?C . chinese-two-byte)
- (?G . greek-two-byte)
- (?H . japanese-hiragana-two-byte)
- (?I . indian-two-byte)
- (?K . japanese-katakana-two-byte)
- (?L . strong-left-to-right)
- (?N . korean-hangul-two-byte)
- (?R . strong-right-to-left)
- (?Y . cyrillic-two-byte)
- (?^ . combining-diacritic)
- (?a . ascii)
- (?b . arabic)
- (?c . chinese)
- (?e . ethiopic)
- (?g . greek)
- (?h . korean)
- (?i . indian)
- (?j . japanese)
- (?k . japanese-katakana)
- (?l . latin)
- (?o . lao)
- (?q . tibetan)
- (?r . japanese-roman)
- (?t . thai)
- (?v . vietnamese)
- (?w . hebrew)
- (?y . cyrillic)
- (?| . can-break)))))
- (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)))))
+ (let* ((sym (assq category-code
+ '((?\s . space-for-indent)
+ (?. . base)
+ (?0 . consonant)
+ (?1 . base-vowel)
+ (?2 . upper-diacritical-mark)
+ (?3 . lower-diacritical-mark)
+ (?4 . tone-mark)
+ (?5 . symbol)
+ (?6 . digit)
+ (?7 . vowel-modifying-diacritical-mark)
+ (?8 . vowel-sign)
+ (?9 . semivowel-lower)
+ (?< . not-at-end-of-line)
+ (?> . not-at-beginning-of-line)
+ (?A . alpha-numeric-two-byte)
+ (?C . chinese-two-byte)
+ (?G . greek-two-byte)
+ (?H . japanese-hiragana-two-byte)
+ (?I . indian-two-byte)
+ (?K . japanese-katakana-two-byte)
+ (?L . strong-left-to-right)
+ (?N . korean-hangul-two-byte)
+ (?R . strong-right-to-left)
+ (?Y . cyrillic-two-byte)
+ (?^ . combining-diacritic)
+ (?a . ascii)
+ (?b . arabic)
+ (?c . chinese)
+ (?e . ethiopic)
+ (?g . greek)
+ (?h . korean)
+ (?i . indian)
+ (?j . japanese)
+ (?k . japanese-katakana)
+ (?l . latin)
+ (?o . lao)
+ (?q . tibetan)
+ (?r . japanese-roman)
+ (?t . thai)
+ (?v . vietnamese)
+ (?w . hebrew)
+ (?y . cyrillic)
+ (?| . can-break))))
+ (item (list 'category (if sym (cdr sym) category-code))))
+ (if negated (list 'not item) item)))
(defun xr--char-syntax (negated syntax-code)
(let ((sym (assq syntax-code