]> git.eshelyaron.com Git - emacs.git/commitdiff
Checkdoc would bug out on empty files
authorLars Ingebrigtsen <larsi@gnus.org>
Tue, 9 Jul 2019 16:24:26 +0000 (18:24 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Tue, 9 Jul 2019 16:45:18 +0000 (18:45 +0200)
* lisp/emacs-lisp/checkdoc.el (checkdoc--next-docstring): Don't
bug out on malformed Emacs Lisp (bug#34760).
(checkdoc-file-comments-engine): Don't bug out on empty buffers.

lisp/emacs-lisp/checkdoc.el

index 3e3246352a2ed099d6cc6729322d2c4eeba6153a..830743f5f89bbd12620150d27b460ef1204c2fa4 100644 (file)
@@ -929,7 +929,10 @@ don't move point."
   (pcase (save-excursion (condition-case nil
                              (read (current-buffer))
                            ;; Conservatively skip syntax errors.
-                           (invalid-read-syntax)))
+                           (invalid-read-syntax)
+                           ;; Don't bug out if the file is empty (or a
+                           ;; definition ends prematurely.
+                           (end-of-file)))
     (`(,(or 'defun 'defvar 'defcustom 'defmacro 'defconst 'defsubst 'defadvice)
        ,(pred symbolp)
        ;; Require an initializer, i.e. ignore single-argument `defvar'
@@ -2250,7 +2253,10 @@ Code:, and others referenced in the style guide."
                    (re-search-forward "^(require" nil t)
                    (re-search-forward "^(" nil t))
                (beginning-of-line))
-              (t (re-search-forward ";;; .* --- .*\n")))
+              ((not (re-search-forward ";;; .* --- .*\n" nil t))
+                (checkdoc-create-error
+                 "You should have a summary line (\";;; .* --- .*\")"
+                 nil nil t)))
              (if (checkdoc-y-or-n-p
                   "You should have a \";;; Commentary:\", add one? ")
                  (insert "\n;;; Commentary:\n;; \n\n")