[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/relint 9238375 07/10: Detect more regexps in defcustom
From: |
Mattias Engdegård |
Subject: |
[elpa] externals/relint 9238375 07/10: Detect more regexps in defcustom alists |
Date: |
Sun, 4 Aug 2019 13:42:48 -0400 (EDT) |
branch: externals/relint
commit 923837551e58c823e0e9f371dc068fe02e5adec5
Author: Mattias Engdegård <address@hidden>
Commit: Mattias Engdegård <address@hidden>
Detect more regexps in defcustom alists
Better type matching, and also consider alists where the values are regexps.
---
relint.el | 38 ++++++++++++++++++++++++++++++--------
1 file changed, 30 insertions(+), 8 deletions(-)
diff --git a/relint.el b/relint.el
index 3d85222..21083e0 100644
--- a/relint.el
+++ b/relint.el
@@ -757,6 +757,12 @@ evaluated are nil."
(stringp (car elem)))
(relint--check-re-string (car elem) name file pos path)))))
+(defun relint--check-alist-cdr (form name file pos path)
+ "Check an alist whose cdrs are regexps."
+ (dolist (elem (relint--get-list form file pos path))
+ (when (and (consp elem)
+ (stringp (cdr elem)))
+ (relint--check-re-string (cdr elem) name file pos path))))
(defun relint--check-font-lock-keywords (form name file pos path)
"Check a font-lock-keywords list. A regexp can be found in an element,
@@ -978,6 +984,11 @@ character alternative: `[' followed by a regexp-generating
expression."
(setq index (+ index 2))
(setq args (cddr args)))))
+(defsubst relint--defcustom-type-regexp-p (type)
+ (or (eq type 'regexp)
+ (and (consp type)
+ (eq (car type) 'regexp))))
+
(defun relint--check-form-recursively-2 (form file pos path)
(pcase form
(`(,(or 'looking-at 're-search-forward 're-search-backward
@@ -1039,14 +1050,28 @@ character alternative: `[' followed by a
regexp-generating expression."
(relint--eval-or-nil (plist-get (cdr rest) :type)))))
(when (symbolp name)
(cond
- ((or (eq type 'regexp)
+ ((or (relint--defcustom-type-regexp-p type)
(string-match-p (rx (or "-regexp" "-re" "-regex" "-pattern")
eos)
(symbol-name name)))
(relint--check-re re-arg name file pos (cons 2 path))
(when (eq (car form) 'defcustom)
(relint--check-defcustom-re form name file pos path))
(push name relint--checked-variables))
- ((or (equal type '(repeat regexp))
+ ((and (consp type)
+ (eq (car type) 'alist)
+ (relint--defcustom-type-regexp-p
+ (plist-get (cdr type) :key-type)))
+ (relint--check-list-any re-arg name file pos (cons 2 path))
+ (push name relint--checked-variables))
+ ((and (consp type)
+ (eq (car type) 'alist)
+ (relint--defcustom-type-regexp-p
+ (plist-get (cdr type) :value-type)))
+ (relint--check-alist-cdr re-arg name file pos (cons 2 path))
+ (push name relint--checked-variables))
+ ((or (and (consp type)
+ (eq (car type) 'repeat)
+ (relint--defcustom-type-regexp-p (cadr type)))
(string-match-p (rx (or (or "-regexps" "-regexes")
(seq (or "-regexp" "-re" "-regex")
"-list"))
@@ -1062,12 +1087,9 @@ character alternative: `[' followed by a
regexp-generating expression."
(relint--check-compilation-error-regexp-alist-alist
re-arg name file pos (cons 2 path))
(push name relint--checked-variables))
- ((or (and (consp type)
- (eq (car type) 'alist)
- (eq (plist-get (cdr type) :key-type) 'regexp))
- (string-match-p (rx (or "-regexp" "-re" "-regex" "-pattern")
- "-alist" eos)
- (symbol-name name)))
+ ((string-match-p (rx (or "-regexp" "-re" "-regex" "-pattern")
+ "-alist" eos)
+ (symbol-name name))
(relint--check-list-any re-arg name file pos (cons 2 path))
(push name relint--checked-variables))
((string-match-p (rx "-mode-alist" eos)
- [elpa] externals/relint updated (e049e93 -> bc001eb), Mattias Engdegård, 2019/08/04
- [elpa] externals/relint c5ac726 03/10: Handle rx `literal' and `regexp' forms correctly, Mattias Engdegård, 2019/08/04
- [elpa] externals/relint 77c3b87 04/10: Improved source traversal towards location, Mattias Engdegård, 2019/08/04
- [elpa] externals/relint 1dc96b5 05/10: Make font-lock-keywords errors easier to find, Mattias Engdegård, 2019/08/04
- [elpa] externals/relint bc001eb 10/10: Increment version to 1.9, Mattias Engdegård, 2019/08/04
- [elpa] externals/relint 963e232 02/10: Check more defcustom strings, Mattias Engdegård, 2019/08/04
- [elpa] externals/relint c08baf2 06/10: Quote symbols with ' instead of ` in pcase, Mattias Engdegård, 2019/08/04
- [elpa] externals/relint 9238375 07/10: Detect more regexps in defcustom alists,
Mattias Engdegård <=
- [elpa] externals/relint 943c728 08/10: Indentation fixes, Mattias Engdegård, 2019/08/04
- [elpa] externals/relint 298d407 01/10: Restructure `cond' expressions for better compilation, Mattias Engdegård, 2019/08/04
- [elpa] externals/relint 2e0bb22 09/10: Keep track of local variable bindings, Mattias Engdegård, 2019/08/04