]> git.eshelyaron.com Git - emacs.git/commitdiff
checkdoc: Flag formatting mistakes in warnings
authorStefan Kangas <stefankangas@gmail.com>
Sun, 7 Jul 2024 11:37:55 +0000 (13:37 +0200)
committerEshel Yaron <me@eshelyaron.com>
Mon, 8 Jul 2024 20:57:17 +0000 (22:57 +0200)
* lisp/emacs-lisp/checkdoc.el (checkdoc-message-text-next-string)
(checkdoc-message-text-engine): Flag formatting mistakes in warnings.
(checkdoc--warning-function-re): New variable.

(cherry picked from commit e738c387dac674092eab4b5b32efd9fb6726dee6)

etc/NEWS
lisp/emacs-lisp/checkdoc.el

index ba58fa7b319f203c9a265202a1bdd848da718bfd..0c9eb82518a5838a13c063c0e6dc3da445a79b77 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -90,6 +90,11 @@ those versions can't install packages where that line is missing.
 This change affects both 'M-x checkdoc' and the corresponding flymake
 backend.
 
+---
+*** Checkdoc will now flag incorrect formatting in warnings.
+This affects calls to 'warn', 'lwarn', 'display-warning', and
+'message-box'.
+
 \f
 * New Modes and Packages in Emacs 31.1
 
index 945a38c89d6f689a2890860408d77836c7e6b052..d7e8c77407c3ecfe93281ed1abb921f1775ea4ee 100644 (file)
@@ -2588,6 +2588,11 @@ The default boundary is the entire buffer."
       (setq e (checkdoc-message-text-engine type)))
     e))
 
+(defvar checkdoc--warning-function-re
+  (rx (or "display-warning" "org-display-warning"
+          "warn" "lwarn"
+          "message-box")))
+
 (defun checkdoc-message-text-next-string (end)
   "Move cursor to the next checkable message string after point.
 Return the message classification.
@@ -2600,6 +2605,7 @@ Argument END is the maximum bounds to search in."
                      (group
                       (or (seq (* (or wordchar (syntax symbol)))
                                "error")
+                          (regexp checkdoc--warning-function-re)
                           (seq (* (or wordchar (syntax symbol)))
                                (or "y-or-n-p" "yes-or-no-p")
                                (? "-with-timeout"))
@@ -2607,8 +2613,13 @@ Argument END is the maximum bounds to search in."
                      (+ (any "\n\t ")))
                  end t))
       (let* ((fn (match-string 1))
-            (type (cond ((string-match "error" fn)
-                         'error)
+             (type (cond ((string-match "error" fn)
+                          'error)
+                         ((string-match (rx bos
+                                            (regexp checkdoc--warning-function-re)
+                                            eos)
+                                        fn)
+                          'warning)
                         (t 'y-or-n-p))))
        (if (string-match "checkdoc-autofix-ask-replace" fn)
            (progn (forward-sexp 2)
@@ -2689,6 +2700,10 @@ Argument TYPE specifies the type of question, such as `error' or `y-or-n-p'."
       (setq type
             (cond ((looking-at "(error")
                    'error)
+                  ((looking-at
+                    (rx "(" (regexp checkdoc--warning-function-re)
+                        (syntax whitespace)))
+                   'warning)
                   (t 'y-or-n-p)))))
   (let ((case-fold-search nil))
     (or