]> code.delx.au - gnu-emacs/commitdiff
checkdoc.el (checkdoc-file): New function
authorOleh Krehel <ohwoeowho@gmail.com>
Mon, 8 Jun 2015 06:30:32 +0000 (08:30 +0200)
committerOleh Krehel <ohwoeowho@gmail.com>
Mon, 8 Jun 2015 06:33:21 +0000 (08:33 +0200)
* lisp/emacs-lisp/checkdoc.el (checkdoc-error): When
  `checkdoc-diagnostic-buffer' is set to "*warn*", print the warning
  to the standard output.

(bug#20754)

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

index 89528690e40507ef8eb6f88a8a2e9774539b3bfa..51d0a5f4fecfd401929a5e4ce0c6d1499901a3e1 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -84,6 +84,10 @@ command line when `initial-buffer-choice' is non-nil.
 \f
 * Changes in Emacs 25.1
 
+** New function `checkdoc-file' checks for style errors.
+It's meant for use together with `compile':
+emacs -batch --eval "(checkdoc-file \"subr.el\")"
+
 ** New command `comment-line' bound to `C-x C-;'.
 
 ** New function `custom-prompt-customize-unsaved-options' checks for
index 4761ac5e6fc0879f59d46b700237f8ae2067a73b..869ae431950f2542d8b20f39add6c1a90e765f5a 100644 (file)
@@ -870,6 +870,13 @@ otherwise stop after the first error."
        (if take-notes (checkdoc-show-diagnostics))
        (message "Checking buffer for style...Done."))))
 
+;;;###autoload
+(defun checkdoc-file (file)
+  "Check FILE for document, comment, error style, and rogue spaces."
+  (with-current-buffer (find-file-noselect file)
+    (let ((checkdoc-diagnostic-buffer "*warn*"))
+      (checkdoc-current-buffer t))))
+
 ;;;###autoload
 (defun checkdoc-start (&optional take-notes)
   "Start scanning the current buffer for documentation string style errors.
@@ -2611,16 +2618,16 @@ function called to create the messages."
   "Store POINT and MSG as errors in the checkdoc diagnostic buffer."
   (setq checkdoc-pending-errors t)
   (let ((text (list "\n" (checkdoc-buffer-label) ":"
-                   (int-to-string
-                    (count-lines (point-min) (or point (point-min))))
-                   ": " msg)))
-    (with-current-buffer (get-buffer checkdoc-diagnostic-buffer)
-      (let ((inhibit-read-only t)
-            (pt (point-max)))
-        (goto-char pt)
-        (apply #'insert text)
-        (when noninteractive
-          (warn (buffer-substring pt (point-max))))))))
+                    (int-to-string
+                     (count-lines (point-min) (or point (point-min))))
+                    ": " msg)))
+    (if (string= checkdoc-diagnostic-buffer "*warn*")
+        (warn (apply #'concat text))
+      (with-current-buffer (get-buffer checkdoc-diagnostic-buffer)
+          (let ((inhibit-read-only t)
+                (pt (point-max)))
+            (goto-char pt)
+            (apply #'insert text))))))
 
 (defun checkdoc-show-diagnostics ()
   "Display the checkdoc diagnostic buffer in a temporary window."