[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/xr 054824b57b 4/7: Add check for \(:? as a typo for \(?
From: |
ELPA Syncer |
Subject: |
[elpa] externals/xr 054824b57b 4/7: Add check for \(:? as a typo for \(?: (#6) |
Date: |
Tue, 1 Aug 2023 09:59:28 -0400 (EDT) |
branch: externals/xr
commit 054824b57b6adc058ea966b8fa5364a9c461ab43
Author: Mattias EngdegÄrd <mattiase@acm.org>
Commit: Mattias EngdegÄrd <mattiase@acm.org>
Add check for \(:? as a typo for \(?: (#6)
Only enabled for checks = `all`.
Suggested by Basil Contovounesios.
---
README | 6 ++++++
xr-test.el | 5 ++++-
xr.el | 9 +++++++++
3 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/README b/README
index 07b3d76516..fe9ae7cc11 100644
--- a/README
+++ b/README
@@ -247,6 +247,12 @@ The xr package can be used interactively or by other code
as a library.
In general, A?, where A matches the empty string, can be
simplified to just A.
+ - Possibly mistyped ':?' at start of group
+
+ A group starts as \(:? which makes it likely that it was really
+ meant to be \(?: -- ie, a non-capturing group.
+ This check is only enable when CHECKS=all.
+
- Unnecessarily escaped 'X'
A character is backslash-escaped in a skip set despite not being
diff --git a/xr-test.el b/xr-test.el
index 4e8d1fadfc..4166766dc2 100644
--- a/xr-test.el
+++ b/xr-test.el
@@ -488,7 +488,6 @@
'((4 . "Suspect character range `+-/': should `-' be literal?")
(10 . "Suspect character range `&-+': should `-' be literal?"))
nil)))
-
(should
(equal
(xr-lint "[ \\t][-.\\d][\\Sw][\\rnt]" nil checks)
@@ -496,6 +495,10 @@
'((2 . "Possibly erroneous `\\t' in character alternative")
(8 . "Possibly erroneous `\\d' in character alternative")
(12 . "Possibly erroneous `\\S' in character alternative")))))
+ (should (equal (xr-lint "\\(?:ta\\)\\(:?da\\)\\(:?\\)" nil checks)
+ (if (eq checks 'all)
+ '((10 . "Possibly mistyped `:?' at start of group"))
+ nil)))
))))
(ert-deftest xr-lint-repetition-of-empty ()
diff --git a/xr.el b/xr.el
index f81a4d9e5e..14231ea796 100644
--- a/xr.el
+++ b/xr.el
@@ -686,6 +686,15 @@ like (* (* X) ... (* X))."
(goto-char (match-end 0))
(string-to-number (match-string 1)))
(t (error "Invalid \\(? syntax"))))
+ (when (and (eq checks 'all)
+ (eq (following-char) ?:)
+ (eq (char-after (1+ (point))) ??)
+ ;; suppress if the group ends after the :?
+ (not (looking-at-p (rx ":?\\)"))))
+ (xr--report
+ warnings (point)
+ (format-message
+ "Possibly mistyped `:?' at start of group")))
'unnumbered))
(group (xr--parse-alt warnings purpose checks))
;; simplify - group has an implicit seq
- [elpa] externals/xr updated (4a1b867438 -> 2d7bedc104), ELPA Syncer, 2023/08/01
- [elpa] externals/xr 8bdec5e753 1/7: Add `checks` arguments to xr-lint and propagate it, ELPA Syncer, 2023/08/01
- [elpa] externals/xr eb4dd40a92 5/7: Add check for or-pattern that could be character alternatives, ELPA Syncer, 2023/08/01
- [elpa] externals/xr d1131ce501 2/7: Add check for [+-X] and [X-+], ELPA Syncer, 2023/08/01
- [elpa] externals/xr 2d7bedc104 7/7: Increment version to 1.24, ELPA Syncer, 2023/08/01
- [elpa] externals/xr 658f469058 3/7: Add check for erroneous escape sequences in character alternatives, ELPA Syncer, 2023/08/01
- [elpa] externals/xr 054824b57b 4/7: Add check for \(:? as a typo for \(?: (#6),
ELPA Syncer <=
- [elpa] externals/xr 699521793d 6/7: Add check for repetition of effective repetition, ELPA Syncer, 2023/08/01