[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/xr c98bb7b 03/10: Handle whitespace and word syntax sub
From: |
Mattias Engdegård |
Subject: |
[elpa] externals/xr c98bb7b 03/10: Handle whitespace and word syntax subsumption in one place |
Date: |
Sun, 3 May 2020 11:13:07 -0400 (EDT) |
branch: externals/xr
commit c98bb7bcf319bca7c42038c51a92ed78f5e439d7
Author: Mattias Engdegård <address@hidden>
Commit: Mattias Engdegård <address@hidden>
Handle whitespace and word syntax subsumption in one place
Use the more elaborate code already in place for charsets.
---
xr.el | 33 +++++++++++++++++----------------
1 file changed, 17 insertions(+), 16 deletions(-)
diff --git a/xr.el b/xr.el
index 3e09ac0..fa89862 100644
--- a/xr.el
+++ b/xr.el
@@ -1042,22 +1042,23 @@ A-SETS and B-SETS are arguments to `any'."
(defun xr--syntax-superset-of-rx-p (syntax negated rx)
"Whether SYNTAX, possibly NEGATED, is a superset of RX."
- ;; Syntax tables vary, but we make a (quite conservative) guess.
- (let* ((always-set
- ;; Characters we think always will be in the syntax set.
- '((whitespace " \t")
- (word "A-Za-z0-9")
- (open-parenthesis "([")
- (close-parenthesis "])")))
- (never-set
- ;; Characters we think never will be in the syntax set.
- '((whitespace "!-~")
- (punctuation "A-Za-z0-9")
- (open-parenthesis "\x00- A-Za-z0-9")
- (close-parenthesis "\x00- A-Za-z0-9")))
- (set (assq syntax (if negated never-set always-set))))
- (and set
- (xr--char-superset-of-rx-p (cdr set) nil rx))))
+ (cond
+ ((eq syntax 'whitespace) (xr--char-superset-of-rx-p '(space) negated rx))
+ ((eq syntax 'word) (xr--char-superset-of-rx-p '(word) negated rx))
+ (t
+ ;; Syntax tables vary, but we make a fairly conservative guess.
+ (let* ((always-set
+ ;; Characters we think always will be in the syntax set.
+ '((open-parenthesis "([")
+ (close-parenthesis "])")))
+ (never-set
+ ;; Characters we think never will be in the syntax set.
+ '((punctuation "A-Za-z0-9") ; NOT the same as [:punct:]!
+ (open-parenthesis "\000-\037A-Za-z0-9" " \177")
+ (close-parenthesis "\000-\037A-Za-z0-9" " \177")))
+ (set (assq syntax (if negated never-set always-set))))
+ (and set
+ (xr--char-superset-of-rx-p (cdr set) nil rx))))))
(defun xr--expand-strings (rx)
"Expand strings to characters or seqs of characters.
- [elpa] externals/xr updated (434b300 -> 35dbbeb), Mattias Engdegård, 2020/05/03
- [elpa] externals/xr e5b51bf 01/10: Add wrapped subsumption in repeated forms, Mattias Engdegård, 2020/05/03
- [elpa] externals/xr f3b61ef 05/10: Fix false negative in empty string repetition check, Mattias Engdegård, 2020/05/03
- [elpa] externals/xr c98bb7b 03/10: Handle whitespace and word syntax subsumption in one place,
Mattias Engdegård <=
- [elpa] externals/xr c7e7557 07/10: Broaden anchor check to check more paths, Mattias Engdegård, 2020/05/03
- [elpa] externals/xr d752aab 09/10: Use "option" instead of "repetition" in diagnostics for ? and ??, Mattias Engdegård, 2020/05/03
- [elpa] externals/xr c6e12b7 04/10: Handle \w and \W in subsumption checks, Mattias Engdegård, 2020/05/03
- [elpa] externals/xr 21eab3c 06/10: Check for bol, eol and eos in conflict with other expressions, Mattias Engdegård, 2020/05/03
- [elpa] externals/xr 7160235 02/10: Refactor repetition subsumption check to avoid code duplication, Mattias Engdegård, 2020/05/03
- [elpa] externals/xr d0b09e1 08/10: Add filename-specific checks, Mattias Engdegård, 2020/05/03
- [elpa] externals/xr 35dbbeb 10/10: Increment version to 1.19, Mattias Engdegård, 2020/05/03