aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuri Linkov2026-01-30 09:41:42 +0200
committerJuri Linkov2026-01-30 09:41:42 +0200
commit1ff0c58fee23356b3a3ef1c7fee24e22fa020356 (patch)
treeb0ffa016b27acfb6454484c0656843d2db0be5cf
parent3584a762b8cbfb6e13011827ec5934f039344d0f (diff)
downloademacs-1ff0c58fee23356b3a3ef1c7fee24e22fa020356.tar.gz
emacs-1ff0c58fee23356b3a3ef1c7fee24e22fa020356.zip
New function 'checkdoc-batch' (bug#80199)
* lisp/emacs-lisp/checkdoc.el (checkdoc--batch-flag): New variable. (checkdoc-rogue-spaces, checkdoc-message-text): Use it along the check for interactive calls to be able to collect errors in the diagnostic buffer. (checkdoc-show-diagnostics): Don't show the diagnostic buffer when 'checkdoc--batch-flag' is non-nil. (checkdoc-batch): New function to check the buffer and print the content of the diagnostic buffer.
-rw-r--r--etc/NEWS5
-rw-r--r--lisp/emacs-lisp/checkdoc.el29
2 files changed, 30 insertions, 4 deletions
diff --git a/etc/NEWS b/etc/NEWS
index 1838a1ec3e5..eca0c070783 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -2087,6 +2087,11 @@ for docstrings where symbols 'nil' and 't' are in quotes.
2087In most cases, having it enabled leads to a large amount of false 2087In most cases, having it enabled leads to a large amount of false
2088positives. 2088positives.
2089 2089
2090---
2091*** New function 'checkdoc-batch'.
2092It checks the buffer in batch mode, prints all found errors
2093and signals the first found error.
2094
2090*** New file-local variable 'lisp-indent-local-overrides'. 2095*** New file-local variable 'lisp-indent-local-overrides'.
2091This variable can be used to locally override the indent specification 2096This variable can be used to locally override the indent specification
2092of symbols. 2097of symbols.
diff --git a/lisp/emacs-lisp/checkdoc.el b/lisp/emacs-lisp/checkdoc.el
index c9f9082a27a..fd226b89fda 100644
--- a/lisp/emacs-lisp/checkdoc.el
+++ b/lisp/emacs-lisp/checkdoc.el
@@ -381,6 +381,9 @@ large number of libraries means it is impractical to fix all
381of these warnings masse. In almost any other case, setting 381of these warnings masse. In almost any other case, setting
382this to anything but t is likely to be counter-productive.") 382this to anything but t is likely to be counter-productive.")
383 383
384(defvar checkdoc--batch-flag nil
385 "Non-nil in batch mode.")
386
384(defun checkdoc-list-of-strings-p (obj) 387(defun checkdoc-list-of-strings-p (obj)
385 "Return t when OBJ is a list of strings." 388 "Return t when OBJ is a list of strings."
386 (declare (obsolete list-of-strings-p "29.1")) 389 (declare (obsolete list-of-strings-p "29.1"))
@@ -1063,12 +1066,13 @@ Optional argument INTERACT permits more interactive fixing."
1063 (e (checkdoc-rogue-space-check-engine nil nil interact)) 1066 (e (checkdoc-rogue-space-check-engine nil nil interact))
1064 (checkdoc-generate-compile-warnings-flag 1067 (checkdoc-generate-compile-warnings-flag
1065 (or take-notes checkdoc-generate-compile-warnings-flag))) 1068 (or take-notes checkdoc-generate-compile-warnings-flag)))
1066 (if (not (called-interactively-p 'interactive)) 1069 (if (not (or (called-interactively-p 'interactive) checkdoc--batch-flag))
1067 e 1070 e
1068 (if e 1071 (if e
1069 (message "%s" (checkdoc-error-text e)) 1072 (message "%s" (checkdoc-error-text e))
1070 (checkdoc-show-diagnostics) 1073 (checkdoc-show-diagnostics)
1071 (message "Space Check: done."))))) 1074 (if (called-interactively-p 'interactive)
1075 (message "Space Check: done."))))))
1072 1076
1073;;;###autoload 1077;;;###autoload
1074(defun checkdoc-message-text (&optional take-notes) 1078(defun checkdoc-message-text (&optional take-notes)
@@ -1081,7 +1085,7 @@ Optional argument TAKE-NOTES causes all errors to be logged."
1081 (checkdoc-generate-compile-warnings-flag 1085 (checkdoc-generate-compile-warnings-flag
1082 (or take-notes checkdoc-generate-compile-warnings-flag))) 1086 (or take-notes checkdoc-generate-compile-warnings-flag)))
1083 (setq e (checkdoc-message-text-search)) 1087 (setq e (checkdoc-message-text-search))
1084 (if (not (called-interactively-p 'interactive)) 1088 (if (not (or (called-interactively-p 'interactive) checkdoc--batch-flag))
1085 e 1089 e
1086 (if e 1090 (if e
1087 (user-error "%s" (checkdoc-error-text e)) 1091 (user-error "%s" (checkdoc-error-text e))
@@ -2819,7 +2823,7 @@ function called to create the messages."
2819 2823
2820(defun checkdoc-show-diagnostics () 2824(defun checkdoc-show-diagnostics ()
2821 "Display the checkdoc diagnostic buffer in a temporary window." 2825 "Display the checkdoc diagnostic buffer in a temporary window."
2822 (if checkdoc-pending-errors 2826 (if (and checkdoc-pending-errors (not checkdoc--batch-flag))
2823 (let* ((b (get-buffer checkdoc-diagnostic-buffer)) 2827 (let* ((b (get-buffer checkdoc-diagnostic-buffer))
2824 (win (if b (display-buffer b)))) 2828 (win (if b (display-buffer b))))
2825 (when win 2829 (when win
@@ -2832,6 +2836,23 @@ function called to create the messages."
2832 (setq checkdoc-pending-errors nil) 2836 (setq checkdoc-pending-errors nil)
2833 nil))) 2837 nil)))
2834 2838
2839
2840;;;###autoload
2841(defun checkdoc-batch ()
2842 "Check current buffer in batch mode.
2843Report any errors and signal the first found error."
2844 (when noninteractive
2845 (let ((checkdoc-autofix-flag nil)
2846 (checkdoc--batch-flag t))
2847 (checkdoc-current-buffer t)
2848 (when checkdoc-pending-errors
2849 (when-let* ((b (get-buffer checkdoc-diagnostic-buffer)))
2850 (with-current-buffer b
2851 (princ (buffer-string)))
2852 (terpri))
2853 (checkdoc-current-buffer)))))
2854
2855
2835(defun checkdoc-get-keywords () 2856(defun checkdoc-get-keywords ()
2836 "Return a list of package keywords for the current file." 2857 "Return a list of package keywords for the current file."
2837 (save-excursion 2858 (save-excursion