branch: externals/xr commit dec9a2ebc6bc79a1383e10b820e4934176f84b8b Author: Mattias Engdegård <matti...@acm.org> Commit: Mattias Engdegård <matti...@acm.org>
Don't warn about \] Do not warn about an escaped ], since [ needs to be escaped and writing \] is unlikely to be a hidden error. --- xr-test.el | 9 ++++----- xr.el | 4 +++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/xr-test.el b/xr-test.el index c0a86a2..718471d 100644 --- a/xr-test.el +++ b/xr-test.el @@ -268,17 +268,16 @@ '((0 . "Escaped non-special character `{'") (4 . "Unescaped literal `+'") (7 . "Unescaped literal `?'") - (12 . "Escaped non-special character `]'") (14 . "Escaped non-special character `}'")))) (should (equal (xr-lint "\\}\\w\\a\\b\\%") '((0 . "Escaped non-special character `}'") (4 . "Escaped non-special character `a'") (8 . "Escaped non-special character `%'")))) (should (equal (xr-lint "a?+b+?\\(?:c?\\)*d\\{3\\}+e*\\{2,5\\}") - '((2 . "Repetition of repetition") - (14 . "Repetition of repetition") - (21 . "Repetition of repetition") - (24 . "Repetition of repetition")))) + '((2 . "Repetition of repetition") + (14 . "Repetition of repetition") + (21 . "Repetition of repetition") + (24 . "Repetition of repetition")))) ) (provide 'xr-test) diff --git a/xr.el b/xr.el index 6114ee7..f8b83c2 100644 --- a/xr.el +++ b/xr.el @@ -445,11 +445,13 @@ ;; Escaped character. Only \*+?.^$[ really need escaping, but we accept ;; any not otherwise handled character after the backslash since ;; such sequences are found in the wild. - ((looking-at (rx "\\" (group (or (any "\\*+?.^$[") + ((looking-at (rx "\\" (group (or (any "\\*+?.^$[]") (group anything))))) (forward-char 2) (push (match-string 1) sequence) (when (match-beginning 2) + ;; Note that we do not warn about \\], since the symmetry with \\[ + ;; makes it unlikely to be a serious error. (xr--report warnings (match-beginning 0) (format "Escaped non-special character `%s'" (match-string 2)))))