GNU bug report logs -
#5126
23.1; checkdoc-comment-style-hooks stops at first error
Previous Next
Reported by: Kevin Ryde <user42 <at> zip.com.au>
Date: Fri, 4 Dec 2009 22:50:10 UTC
Severity: normal
Tags: notabug
Done: Andrew Hyatt <ahyatt <at> gmail.com>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 5126 in the body.
You can then email your comments to 5126 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#5126
; Package
emacs
.
(Fri, 04 Dec 2009 22:50:11 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Kevin Ryde <user42 <at> zip.com.au>
:
New bug report received and forwarded. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
(Fri, 04 Dec 2009 22:50:11 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):
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.
I hoped the hook functions would instead run like the builtin checks of
checkdoc-file-comments-engine,
(setq err (or (some check)
err))
so that all checks are always run, with an error reported if any one of
them reports an error.
Or alternately perhaps I misunderstand the docstring of
checkdoc-comment-style-hooks, and that a "problem discovered" means
something fatal and unrecoverable, or something, and that hook functions
should almost always return nil no matter what they find.
I threw down the few lines below for a hook run which returns the last
true value, but I'm not sure I like it much. An alternative to picking
out a list of functions from a hook might be a
"run-hook-with-accumulator-function" or even a "map-hook" -- unless that
exists already.
(defun checkdoc-run-hooks-last-true (hookvar)
"Run hooks in HOOKVAR and return the last true value."
(let (ret)
(dolist (func (checkdoc-hook-functions hookvar))
(setq ret (or (funcall func) ret)))))
(defun checkdoc-hook-functions (hookvar)
"Return a list of functions HOOKVAR should run.
HOOKVAR can be a single function or list of functions, the return
is always a list. `t' in a buffer-local value means use the
global `default-value' at that point, and it can likewise be a
function or list."
(let ((hooks (symbol-value hookvar)))
(if (and hooks
;; same test as run_hook_with_args()
(or (not (consp hooks))
(eq 'lambda (car hooks))))
(list hooks) ;; single function listified
;; expand `t' to global value
(apply 'append
(mapcar (lambda (func)
(if (eq t func)
(let ((global (default-value hookvar)))
;; same test as run_hook_with_args()
(if (or (not (consp global))
(eq 'lambda (car global)))
(list global)
global))
(list func)))
hooks)))))
In GNU Emacs 23.1.1 (i486-pc-linux-gnu, GTK+ Version 2.16.5)
of 2009-09-14 on raven, modified by Debian
configured using `configure '--build=i486-linux-gnu' '--host=i486-linux-gnu' '--prefix=/usr' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib' '--localstatedir=/var/lib' '--infodir=/usr/share/info' '--mandir=/usr/share/man' '--with-pop=yes' '--enable-locallisppath=/etc/emacs23:/etc/emacs:/usr/local/share/emacs/23.1/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/23.1/site-lisp:/usr/share/emacs/site-lisp:/usr/share/emacs/23.1/leim' '--with-x=yes' '--with-x-toolkit=gtk' '--with-toolkit-scroll-bars' 'build_alias=i486-linux-gnu' 'host_alias=i486-linux-gnu' 'CFLAGS=-DDEBIAN -g -O2' 'LDFLAGS=-g' 'CPPFLAGS=''
Important settings:
value of $LC_ALL: nil
value of $LC_COLLATE: nil
value of $LC_CTYPE: nil
value of $LC_MESSAGES: nil
value of $LC_MONETARY: nil
value of $LC_NUMERIC: nil
value of $LC_TIME: nil
value of $LANG: en_AU
value of $XMODIFIERS: nil
locale-coding-system: iso-latin-1-unix
default-enable-multibyte-characters: t
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#5126
; Package
emacs
.
(Sat, 09 Jul 2016 13:28:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 5126 <at> debbugs.gnu.org (full text, mbox):
This still is the case in Emacs 25. I agree that this seems like a
problem.
Kevin Ryde <user42 <at> zip.com.au> 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.
>
> I hoped the hook functions would instead run like the builtin checks of
> checkdoc-file-comments-engine,
>
> (setq err (or (some check)
> err))
>
> so that all checks are always run, with an error reported if any one of
> them reports an error.
>
> Or alternately perhaps I misunderstand the docstring of
> checkdoc-comment-style-hooks, and that a "problem discovered" means
> something fatal and unrecoverable, or something, and that hook functions
> should almost always return nil no matter what they find.
>
>
> I threw down the few lines below for a hook run which returns the last
> true value, but I'm not sure I like it much. An alternative to picking
> out a list of functions from a hook might be a
> "run-hook-with-accumulator-function" or even a "map-hook" -- unless that
> exists already.
>
> (defun checkdoc-run-hooks-last-true (hookvar)
> "Run hooks in HOOKVAR and return the last true value."
> (let (ret)
> (dolist (func (checkdoc-hook-functions hookvar))
> (setq ret (or (funcall func) ret)))))
>
> (defun checkdoc-hook-functions (hookvar)
> "Return a list of functions HOOKVAR should run.
> HOOKVAR can be a single function or list of functions, the return
> is always a list. `t' in a buffer-local value means use the
> global `default-value' at that point, and it can likewise be a
> function or list."
> (let ((hooks (symbol-value hookvar)))
> (if (and hooks
> ;; same test as run_hook_with_args()
> (or (not (consp hooks))
> (eq 'lambda (car hooks))))
> (list hooks) ;; single function listified
>
> ;; expand `t' to global value
> (apply 'append
> (mapcar (lambda (func)
> (if (eq t func)
> (let ((global (default-value hookvar)))
> ;; same test as run_hook_with_args()
> (if (or (not (consp global))
> (eq 'lambda (car global)))
> (list global)
> global))
> (list func)))
> hooks)))))
>
>
>
>
> In GNU Emacs 23.1.1 (i486-pc-linux-gnu, GTK+ Version 2.16.5)
> of 2009-09-14 on raven, modified by Debian
> configured using `configure '--build=i486-linux-gnu' '--host=i486-linux-gnu' '--prefix=/usr' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib' '--localstatedir=/var/lib' '--infodir=/usr/share/info' '--mandir=/usr/share/man' '--with-pop=yes' '--enable-locallisppath=/etc/emacs23:/etc/emacs:/usr/local/share/emacs/23.1/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/23.1/site-lisp:/usr/share/emacs/site-lisp:/usr/share/emacs/23.1/leim' '--with-x=yes' '--with-x-toolkit=gtk' '--with-toolkit-scroll-bars' 'build_alias=i486-linux-gnu' 'host_alias=i486-linux-gnu' 'CFLAGS=-DDEBIAN -g -O2' 'LDFLAGS=-g' 'CPPFLAGS=''
>
> Important settings:
> value of $LC_ALL: nil
> value of $LC_COLLATE: nil
> value of $LC_CTYPE: nil
> value of $LC_MESSAGES: nil
> value of $LC_MONETARY: nil
> value of $LC_NUMERIC: nil
> value of $LC_TIME: nil
> value of $LANG: en_AU
> value of $XMODIFIERS: nil
> locale-coding-system: iso-latin-1-unix
> default-enable-multibyte-characters: t
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#5126
; Package
emacs
.
(Fri, 16 Aug 2019 19:15:01 GMT)
Full text and
rfc822 format available.
Message #11 received at 5126 <at> debbugs.gnu.org (full text, mbox):
On Sat 09 Jul 2016 at 09:27, Andrew Hyatt <ahyatt <at> gmail.com> wrote:
> This still is the case in Emacs 25. I agree that this seems like a
> problem.
>
> Kevin Ryde <user42 <at> zip.com.au> 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
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#5126
; Package
emacs
.
(Tue, 20 Aug 2019 17:23:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 5126 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
The bug report is saying that not all checks are run. If you trace your
functions you tested with and run checkdoc, you will find that foobaz is
checked for but not foobar. So not all checks are run. The author of the
bug wants both checked for.
Maybe this bug should be a feature request instead.
Or, maybe it's not a good idea to even do all the checks when only one
error message will be printed. I'm not sure why the author of the bug
thought this was a problem, to be honest.
If someone understands what the benefit would be of running
all checks, please share that info. Otherwise, I'm happy to close this
bug in a few weeks if we don't hear anything.
On Fri, Aug 16, 2019 at 3:14 PM Alex Branham <alex.branham <at> gmail.com> wrote:
> On Sat 09 Jul 2016 at 09:27, Andrew Hyatt <ahyatt <at> gmail.com> wrote:
>
> > This still is the case in Emacs 25. I agree that this seems like a
> > problem.
> >
> > Kevin Ryde <user42 <at> zip.com.au> 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
>
[Message part 2 (text/html, inline)]
Added tag(s) notabug.
Request was from
Andrew Hyatt <ahyatt <at> gmail.com>
to
control <at> debbugs.gnu.org
.
(Wed, 25 Sep 2019 00:43:01 GMT)
Full text and
rfc822 format available.
bug closed, send any further explanations to
5126 <at> debbugs.gnu.org and Kevin Ryde <user42 <at> zip.com.au>
Request was from
Andrew Hyatt <ahyatt <at> gmail.com>
to
control <at> debbugs.gnu.org
.
(Wed, 25 Sep 2019 00:43:01 GMT)
Full text and
rfc822 format available.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Wed, 23 Oct 2019 11:24:05 GMT)
Full text and
rfc822 format available.
This bug report was last modified 5 years and 301 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.