branch: externals/relint commit 12a2b0fafdba26526e2b166a322a6171fac19cc4 Author: Mattias Engdegård <matti...@acm.org> Commit: Mattias Engdegård <matti...@acm.org>
Use regexp in suppression comments This adds flexibility, in particular for coping with different quoting styles. --- README | 6 +++--- relint.el | 10 +++++----- test/6.elisp | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/README b/README index 3ca9499..7a355c4 100644 --- a/README +++ b/README @@ -265,10 +265,10 @@ skip-syntax-backward. To suppress such diagnostics, add a comment on the form - ;; relint suppression: MESSAGE + ;; relint suppression: REGEXP - on the line before the code where the error occurred. MESSAGE is a - substring of the message to be suppressed. Multiple suppression + on the line before the code where the error occurred. REGEXP + matches the message to be suppressed. Multiple suppression comment lines can precede a line of code to eliminate several complaints on the same line. diff --git a/relint.el b/relint.el index d5b329e..b17d451 100644 --- a/relint.el +++ b/relint.el @@ -209,9 +209,9 @@ or nil if no position could be determined." (save-excursion ;; On a preceding line, look for a comment on the form ;; - ;; relint suppression: SUBSTRING + ;; relint suppression: REGEXP ;; - ;; where SUBSTRING is a substring of MESSAGE. There can be + ;; where REGEXP matches MESSAGE. There can be ;; multiple suppression lines preceding a line of code with ;; several errors. (goto-char pos) @@ -221,11 +221,11 @@ or nil if no position could be determined." (not (setq matched (and (looking-at (rx (0+ blank) (1+ ";") (0+ blank) - "relint suppression:" (0+ blank) + "relint suppression:" (1+ blank) (group (0+ nonl) (not (any "\n" blank))))) - (let ((substr (match-string 1))) - (string-match-p (regexp-quote substr) message))))) + (let ((regexp (match-string 1))) + (string-match-p regexp message))))) (looking-at (rx bol (0+ blank) (opt ";" (0+ nonl)) eol)) diff --git a/test/6.elisp b/test/6.elisp index ac07fc1..cbbdf4b 100644 --- a/test/6.elisp +++ b/test/6.elisp @@ -48,8 +48,8 @@ ;; Test suppression (defun test-suppression () - ;; relint suppression: Unescaped literal `$' - ;; relint suppression: Duplicated `a' + ;; relint suppression: Unescaped literal .\$ + ;; relint suppression: Duplicated .a (looking-at "$[aa]")) ;; Test user-defined regexp-generating functions