emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/relint 96e26a5 02/21: Check keyword arguments :regexp a


From: Mattias Engdegård
Subject: [elpa] externals/relint 96e26a5 02/21: Check keyword arguments :regexp and :regex
Date: Sun, 3 May 2020 11:13:34 -0400 (EDT)

branch: externals/relint
commit 96e26a5f8f3967cf5b1e181831e94860f2be6c74
Author: Mattias Engdegård <address@hidden>
Commit: Mattias Engdegård <address@hidden>

    Check keyword arguments :regexp and :regex
---
 relint.el       | 8 +++++++-
 test/2.elisp    | 4 ++++
 test/2.expected | 6 ++++++
 3 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/relint.el b/relint.el
index 567315c..bc4a9af 100644
--- a/relint.el
+++ b/relint.el
@@ -1965,11 +1965,17 @@ directly."
      ;; mutables since all args are evaluated once.
      (let ((index 0))
        (while (consp form)
-         (when (consp (car form))
+         (cond
+          ((consp (car form))
            ;; Check subforms with the assumption that nothing can be mutated,
            ;; since we don't really know what is evaluated when.
            (relint--check-form-recursively-2
             (car form) nil file pos (cons index path)))
+          ((and (memq (car form) '(:regexp :regex))
+                (consp (cdr form)))
+           (relint--check-re (cadr form)
+                             (format "%s parameter" (car form))
+                             file pos (cons (1+ index) path))))
          (setq form (cdr form))
          (setq index (1+ index)))))))
 
diff --git a/test/2.elisp b/test/2.elisp
index 1a2c4ea..a96cef0 100644
--- a/test/2.elisp
+++ b/test/2.elisp
@@ -50,3 +50,7 @@
 
 (defun f6 ()
   (f5 "[aa]" "[bb]" "[cc]" "[dd]" "[ee]"))
+
+(defun f7 ()
+  (alpha beta :regexp "[11]")
+  (gamma :regex "[22]" delta))
diff --git a/test/2.expected b/test/2.expected
index 0bde370..0dbcfc8 100644
--- a/test/2.expected
+++ b/test/2.expected
@@ -133,3 +133,9 @@
 2.elisp:52:31: In call to f5: Duplicated `d' inside character alternative (pos 
2)
   "[dd]"
    ..^
+2.elisp:55:26: In :regexp parameter: Duplicated `1' inside character 
alternative (pos 2)
+  "[11]"
+   ..^
+2.elisp:56:20: In :regex parameter: Duplicated `2' inside character 
alternative (pos 2)
+  "[22]"
+   ..^



reply via email to

[Prev in Thread] Current Thread [Next in Thread]