[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/relint 803579c 01/15: More font-lock-keywords detection
From: |
Mattias Engdeg�rd |
Subject: |
[elpa] externals/relint 803579c 01/15: More font-lock-keywords detection |
Date: |
Sat, 29 Feb 2020 17:22:27 -0500 (EST) |
branch: externals/relint
commit 803579ce0f345d47c7b3cef7b6cee21c83af348c
Author: Mattias Engdegård <address@hidden>
Commit: Mattias Engdegård <address@hidden>
More font-lock-keywords detection
Look at arguments to font-lock-add-keywords, and mutation/binding
of font-lock-defaults and font-lock-keywords.
After a suggestion by Federico Tedin (bug #8).
---
relint.el | 25 +++++++++++++++++--------
test/1.elisp | 1 +
test/1.expected | 48 +++++++++++++++++++++++++++---------------------
test/9.elisp | 5 +++++
test/9.expected | 9 +++++++++
5 files changed, 59 insertions(+), 29 deletions(-)
diff --git a/relint.el b/relint.el
index 3ac29cb..2e14c92 100644
--- a/relint.el
+++ b/relint.el
@@ -1393,10 +1393,13 @@ directly."
(expr (cadr args)))
(relint--check-form-recursively-2
expr mutables file pos (cons i path))
- (if (memq name relint--known-regexp-variables)
- ;; Setting a special buffer-local regexp.
- (relint--check-re expr name file pos (cons i path))
-
+ (cond
+ ((memq name relint--known-regexp-variables)
+ (relint--check-re expr name file pos (cons i path)))
+ ((memq name '(font-lock-defaults font-lock-keywords))
+ (relint--check-font-lock-keywords expr name
+ file pos (cons i path)))
+ (t
;; Invalidate the variable if it was local; otherwise, ignore.
(let ((local (assq name relint--locals)))
(when local
@@ -1405,7 +1408,7 @@ directly."
(let ((val (catch 'relint-eval
(list (relint--eval expr)))))
(and (not (eq val 'no-value))
- val))))))))
+ val)))))))))
(setq args (cddr args))
(setq i (+ i 2)))))
(`(push ,expr ,(and (pred symbolp) name))
@@ -1570,7 +1573,7 @@ directly."
(symbol-name name)))
(relint--check-list re-arg name file pos (cons 2 path))
(push name relint--checked-variables))
- ((string-match-p (rx "-font-lock-keywords")
+ ((string-match-p (rx "font-lock-keywords")
(symbol-name name))
(relint--check-font-lock-keywords re-arg name file pos
(cons 2 path))
@@ -1626,9 +1629,15 @@ directly."
(cons 'val val))))
(list 'expr re-arg))))
(push (cons name new) relint--variables)))))
+ (`(font-lock-add-keywords ,_ ,keywords . ,_)
+ (relint--check-font-lock-keywords
+ keywords (car form) file pos (cons 2 path)))
(`(set (make-local-variable ',name) ,expr)
- (when (memq name relint--known-regexp-variables)
- (relint--check-re expr name file pos (cons 2 path))))
+ (cond ((memq name relint--known-regexp-variables)
+ (relint--check-re expr name file pos (cons 2 path)))
+ ((memq name '(font-lock-defaults font-lock-keywords))
+ (relint--check-font-lock-keywords expr name
+ file pos (cons 2 path)))))
(`(define-generic-mode ,name ,_ ,_ ,font-lock-list ,auto-mode-list . ,_)
(let ((origin (format "define-generic-mode %s" name)))
(relint--check-font-lock-keywords font-lock-list origin
diff --git a/test/1.elisp b/test/1.elisp
index f8f7d87..865d21a 100644
--- a/test/1.elisp
+++ b/test/1.elisp
@@ -30,6 +30,7 @@
(defconst bad-font-lock-keywords '(("[xx]" . tag) "[yy]"))
(defconst more-font-lock-keywords-bad '(("[uu]" . tag) "[vv]"))
+(font-lock-add-keywords 'mymode '(("[ss]" . tag) "[tt]"))
;; Test variable doc string heuristics.
(defconst bad-var-1 "a^"
diff --git a/test/1.expected b/test/1.expected
index 9151270..e5c832d 100644
--- a/test/1.expected
+++ b/test/1.expected
@@ -97,64 +97,70 @@
1.elisp:32:39: In more-font-lock-keywords-bad: Duplicated `v' inside character
alternative (pos 2)
"[vv]"
..^
-1.elisp:35:21: In bad-var-1: Unescaped literal `^' (pos 1)
+1.elisp:33:33: In font-lock-add-keywords (tag): Duplicated `s' inside
character alternative (pos 2)
+ "[ss]"
+ ..^
+1.elisp:33:33: In font-lock-add-keywords: Duplicated `t' inside character
alternative (pos 2)
+ "[tt]"
+ ..^
+1.elisp:36:21: In bad-var-1: Unescaped literal `^' (pos 1)
"a^"
.^
-1.elisp:37:19: In bad-var-2: Duplicated `z' inside character alternative (pos
2)
+1.elisp:38:19: In bad-var-2: Duplicated `z' inside character alternative (pos
2)
"[zz]"
..^
-1.elisp:39:22: In bad-var-3: Reversed range `o-O' matches nothing (pos 1)
+1.elisp:40:22: In bad-var-3: Reversed range `o-O' matches nothing (pos 1)
"[o-O]"
.^
-1.elisp:45:25: In bad-custom-1: Duplicated `n' inside character alternative
(pos 2)
+1.elisp:46:25: In bad-custom-1: Duplicated `n' inside character alternative
(pos 2)
"[nn]"
..^
-1.elisp:49:25: In bad-custom-2: Duplicated `s' inside character alternative
(pos 2)
+1.elisp:50:25: In bad-custom-2: Duplicated `s' inside character alternative
(pos 2)
"[ss]"
..^
-1.elisp:56:9: In bad-custom-3-regexp: Unescaped literal `+' (pos 0)
+1.elisp:57:9: In bad-custom-3-regexp: Unescaped literal `+' (pos 0)
"+a+"
^
-1.elisp:56:9: In bad-custom-3-regexp: Unescaped literal `*' (pos 0)
+1.elisp:57:9: In bad-custom-3-regexp: Unescaped literal `*' (pos 0)
"*b*"
^
-1.elisp:56:9: In bad-custom-3-regexp: Unescaped literal `^' (pos 2)
+1.elisp:57:9: In bad-custom-3-regexp: Unescaped literal `^' (pos 2)
"^c^"
..^
-1.elisp:63:12: In bad-custom-4-regexp: Unescaped literal `+' (pos 0)
+1.elisp:64:12: In bad-custom-4-regexp: Unescaped literal `+' (pos 0)
"+b"
^
-1.elisp:64:25: In bad-custom-5: Unescaped literal `^' (pos 2)
+1.elisp:65:25: In bad-custom-5: Unescaped literal `^' (pos 2)
"^x^"
..^
-1.elisp:68:25: In bad-custom-6: Error: No character class ‘[:bah:]’:
"[[:bah:]]"
-1.elisp:72:25: In bad-custom-7: Duplicated `a' inside character alternative
(pos 2)
+1.elisp:69:25: In bad-custom-6: Error: No character class ‘[:bah:]’:
"[[:bah:]]"
+1.elisp:73:25: In bad-custom-7: Duplicated `a' inside character alternative
(pos 2)
"[aa]"
..^
-1.elisp:79:3: In compilation-error-regexp-alist-alist (aa): Unescaped literal
`^' (pos 1)
+1.elisp:80:3: In compilation-error-regexp-alist-alist (aa): Unescaped literal
`^' (pos 1)
"a^a"
.^
-1.elisp:79:3: In compilation-error-regexp-alist-alist (bb): Unescaped literal
`$' (pos 1)
+1.elisp:80:3: In compilation-error-regexp-alist-alist (bb): Unescaped literal
`$' (pos 1)
"b$b"
.^
-1.elisp:85:3: In define-generic-mode my-mode: Unescaped literal `^' (pos 1)
+1.elisp:86:3: In define-generic-mode my-mode: Unescaped literal `^' (pos 1)
"1^"
.^
-1.elisp:85:3: In define-generic-mode my-mode: Unescaped literal `^' (pos 1)
+1.elisp:86:3: In define-generic-mode my-mode: Unescaped literal `^' (pos 1)
"2^"
.^
-1.elisp:87:3: In define-generic-mode my-mode: Repetition of repetition (pos 2)
+1.elisp:88:3: In define-generic-mode my-mode: Repetition of repetition (pos 2)
"b++"
..^
-1.elisp:93:5: In call to syntax-propertize-rules: Unescaped literal `$' (pos 0)
+1.elisp:94:5: In call to syntax-propertize-rules: Unescaped literal `$' (pos 0)
"$1$"
^
-1.elisp:94:5: In call to syntax-propertize-rules: Unescaped literal `^' (pos 2)
+1.elisp:95:5: In call to syntax-propertize-rules: Unescaped literal `^' (pos 2)
"^2^"
..^
-1.elisp:99:5: In call to syntax-propertize-precompile-rules: Unescaped literal
`$' (pos 0)
+1.elisp:100:5: In call to syntax-propertize-precompile-rules: Unescaped
literal `$' (pos 0)
"$3$"
^
-1.elisp:100:5: In call to syntax-propertize-precompile-rules: Unescaped
literal `^' (pos 2)
+1.elisp:101:5: In call to syntax-propertize-precompile-rules: Unescaped
literal `^' (pos 2)
"^4^"
..^
diff --git a/test/9.elisp b/test/9.elisp
index 9c6e46e..322334f 100644
--- a/test/9.elisp
+++ b/test/9.elisp
@@ -18,3 +18,8 @@
(let* ((comment-start-skip "[kk]")
(comment-end-skip "[ll]"))
(asdf))))
+
+(defun test-9-fl ()
+ (setq-local font-lock-defaults '(("[mm]" . tag)))
+ (setq font-lock-defaults '(("[nn]" . tag)))
+ (set (make-local-variable 'font-lock-defaults) '(("[oo]" . tag))))
diff --git a/test/9.expected b/test/9.expected
index 2400b56..1f51f63 100644
--- a/test/9.expected
+++ b/test/9.expected
@@ -34,3 +34,12 @@
9.elisp:19:30: In comment-end-skip: Duplicated `l' inside character
alternative (pos 2)
"[ll]"
..^
+9.elisp:23:34: In font-lock-defaults (tag): Duplicated `m' inside character
alternative (pos 2)
+ "[mm]"
+ ..^
+9.elisp:24:28: In font-lock-defaults (tag): Duplicated `n' inside character
alternative (pos 2)
+ "[nn]"
+ ..^
+9.elisp:25:50: In font-lock-defaults (tag): Duplicated `o' inside character
alternative (pos 2)
+ "[oo]"
+ ..^
- [elpa] externals/relint updated (3315f03 -> c2d3f3b), Mattias Engdeg�rd, 2020/02/29
- [elpa] externals/relint 55070de 02/15: Update copyright year to 2020, Mattias Engdeg�rd, 2020/02/29
- [elpa] externals/relint a2a29d6 03/15: Scan arguments to search-{forward, backward}-regexp, Mattias Engdeg�rd, 2020/02/29
- [elpa] externals/relint c733b47 05/15: Use text quoting for all messages, Mattias Engdeg�rd, 2020/02/29
- [elpa] externals/relint b46ee8b 04/15: Update copyright year to 2020, Mattias Engdeg�rd, 2020/02/29
- [elpa] externals/relint bb7d8a1 10/15: Fix mistake in previous commit, Mattias Engdeg�rd, 2020/02/29
- [elpa] externals/relint 1741e2c 09/15: Locate error position in 'concat' forms, Mattias Engdeg�rd, 2020/02/29
- [elpa] externals/relint 8cc1017 12/15: Rename relint--pos-from-toplevel-pos-path, Mattias Engdeg�rd, 2020/02/29
- [elpa] externals/relint 9de65a6 11/15: Remove package description in relint.el, Mattias Engdeg�rd, 2020/02/29
- [elpa] externals/relint c33b893 06/15: Refactor error reporting, Mattias Engdeg�rd, 2020/02/29
- [elpa] externals/relint 803579c 01/15: More font-lock-keywords detection,
Mattias Engdeg�rd <=
- [elpa] externals/relint 47490f3 08/15: Add relint-buffer for easier use of relint as a library, Mattias Engdeg�rd, 2020/02/29
- [elpa] externals/relint 159a210 13/15: Simplify line/column computation and reindent, Mattias Engdeg�rd, 2020/02/29
- [elpa] externals/relint c2d3f3b 15/15: Increment version to 1.14, Mattias Engdeg�rd, 2020/02/29
- [elpa] externals/relint 4a8b0ef 14/15: Return position of both expression and error from relint-buffer, Mattias Engdeg�rd, 2020/02/29
- [elpa] externals/relint 7b93662 07/15: Report error position inside string literals, Mattias Engdeg�rd, 2020/02/29