branch: externals/relint commit eb178d5f9d529ccc29785e277683faa661e73be4 Author: Mattias Engdegård <matti...@acm.org> Commit: Mattias Engdegård <matti...@acm.org>
Check assignments to imenu-generic-expression --- relint.el | 16 +++++++++++++++- test/9.elisp | 5 +++++ test/9.expected | 3 +++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/relint.el b/relint.el index 0c1653d..31f1887 100644 --- a/relint.el +++ b/relint.el @@ -1152,6 +1152,14 @@ or in the car of an element." (relint--check-re-string (car elem) ident file pos p))))) form path)) +(defun relint--check-imenu-generic-expression (form name file pos path) + (relint--eval-list-iter + (lambda (elem elem-path literal) + (when (and (consp elem) (consp (cdr elem)) (stringp (cadr elem))) + (relint--check-re-string + (cadr elem) name file pos (if literal (cons 1 elem-path) elem-path)))) + form path)) + (defun relint--check-compilation-error-regexp-alist-alist (form name file pos path) (relint--eval-list-iter @@ -1701,6 +1709,9 @@ directly." ((memq name '(font-lock-defaults font-lock-keywords)) (relint--check-font-lock-keywords expr name file pos (cons i path))) + ((eq name 'imenu-generic-expression) + (relint--check-imenu-generic-expression + expr name file pos (cons i path))) (t ;; Invalidate the variable if it was local; otherwise, ignore. (let ((local (assq name relint--locals))) @@ -1948,7 +1959,10 @@ directly." (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))))) + file pos (cons 2 path))) + ((eq name 'imenu-generic-expression) + (relint--check-imenu-generic-expression + 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/9.elisp b/test/9.elisp index 322334f..4a37174 100644 --- a/test/9.elisp +++ b/test/9.elisp @@ -23,3 +23,8 @@ (setq-local font-lock-defaults '(("[mm]" . tag))) (setq font-lock-defaults '(("[nn]" . tag))) (set (make-local-variable 'font-lock-defaults) '(("[oo]" . tag)))) + +(defun test-9-ge () + (setq-local imenu-generic-expression + '((nil "oh" 0) + ("*more*" "+a+" 0)))) diff --git a/test/9.expected b/test/9.expected index ab3f06e..7bab898 100644 --- a/test/9.expected +++ b/test/9.expected @@ -43,3 +43,6 @@ 9.elisp:25:56: In font-lock-defaults (tag): Duplicated `o' inside character alternative (pos 2) "[oo]" ..^ +9.elisp:30:28: In imenu-generic-expression: Unescaped literal `+' (pos 0) + "+a+" + ^