Subject: bug#5126: 23.1; checkdoc-comment-style-hooks stops at first error

From: Alex Branham <[email-masked]>
Date: Fri, 16 Aug 2019 14:14:08 -0500

On Sat 09 Jul 2016 at 09:27, Andrew Hyatt <[email-masked]> wrote:

> This still is the case in Emacs 25. I agree that this seems like a
> problem.
>
> Kevin Ryde <[email-masked]> writes:
>
>> checkdoc-comment-style-hooks is run by checkdoc-file-comments-engine
>> with run-hook-with-args-until-success, which means if one of the hook
>> functions returns an error string (as described in the hook's docstring)
>> then no further functions are run.

Maybe I'm misunderstanding this bug report, but this works for me:

;; foobar
(defun my/checkdoc-comments-foobar ()
  "Check if foobar is in a comment."
  (save-excursion
    (goto-char (point-min))
    (unless (re-search-forward "^;; foobar" nil t)
      (checkdoc-create-error
       ";; foobar doesn't exist"
       (1- (point-max)) (point-max)))))

(defun my/checkdoc-comments-foobaz ()
  "Check if foobaz is in a comment."
  (save-excursion
    (goto-char (point-min))
    (unless (re-search-forward "^;; foobaz" nil t)
      (checkdoc-create-error
       ";; foobaz doesn't exist"
       (1- (point-max)) (point-max)))))

(add-hook 'checkdoc-comment-style-functions #'my/checkdoc-comments-foobar)
(add-hook 'checkdoc-comment-style-functions #'my/checkdoc-comments-foobaz)

Now checkdoc warns that foobaz is missing. You can change foobar to
foobaz and it warns that foobar is missing. Can we close this bug report?

Alex