GNU bug report logs -
#78543
29.2; checkdoc misses some CL (cl-lib) constructs.
Previous Next
To reply to this bug, email your comments to 78543 AT debbugs.gnu.org.
There is no need to reopen the bug first.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78543
; Package
emacs
.
(Wed, 21 May 2025 20:40:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Marco Antoniotti <marcoxa <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Wed, 21 May 2025 20:40:01 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Hi
The problem is with `checkdoc` not correctly handling some docstring
in `cl-lib` style declarations.
I have a function like
```
(cl-defun funky-keys (&key ((:this that) 42) &aux (the-beast 666))
"Do something with THAT (passed via :THIS)"
...
)
```
checkdoc insists on flagging :THIS and THE-BEAST as missing from the
docstring.
Another one is the following.
```
(cl-defgeneric gf (a s d f)
(:documentation "Munge A, S, D, and F."))
```
checkdoc does not recognize the :documentation option (which is valid
according to cl-lib).
This problem is still visible in 30.1
All the best
Marco
--
Marco Antoniotti
Somewhere over the Rainbow
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78543
; Package
emacs
.
(Sat, 31 May 2025 11:08:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 78543 <at> debbugs.gnu.org (full text, mbox):
> From: Marco Antoniotti <marcoxa <at> gmail.com>
> Date: Wed, 21 May 2025 22:38:48 +0200
>
> The problem is with `checkdoc` not correctly handling some docstring
> in `cl-lib` style declarations.
>
> I have a function like
>
> ```
> (cl-defun funky-keys (&key ((:this that) 42) &aux (the-beast 666))
> "Do something with THAT (passed via :THIS)"
> ...
> )
> ```
>
> checkdoc insists on flagging :THIS and THE-BEAST as missing from the docstring.
>
> Another one is the following.
>
> ```
> (cl-defgeneric gf (a s d f)
> (:documentation "Munge A, S, D, and F."))
> ```
>
> checkdoc does not recognize the :documentation option (which is valid according to cl-lib).
>
> This problem is still visible in 30.1
Sigh. This is notoriously under-documented in the cl.info manual.
After reading and re-reading the node "Argument Lists" there, I
believe that we expect :this to be referenced as "THIS" (without the
leading colon) in the doc string, since argument references in doc
strings should be words, not symbols, and ':' is not a
word-constituent character. Also, I believe that THE-BEAST should
indeed be mentioned in the doc string. This:
(cl-defun funky-keys (&key ((:this that) 42) &aux (the-beast 666))
"Do something with THAT (passed via THIS), binding THE-BEAST to 666."
nil
)
passes the checkdoc tests, if we install the simple patch below.
But since I'm very far from being an expert of cl-defun and its
correct usage, I invite CL experts to chime in and provide their
opinions.
Here's the patch which I will install barring any objections:
diff --git a/lisp/emacs-lisp/checkdoc.el b/lisp/emacs-lisp/checkdoc.el
index 355a0c5..f9fab0b 100644
--- a/lisp/emacs-lisp/checkdoc.el
+++ b/lisp/emacs-lisp/checkdoc.el
@@ -1761,24 +1761,31 @@ checkdoc-this-string-valid-engine
;; Addendum: Make sure they appear in the doc in the same
;; order that they are found in the arg list.
- (let ((args (nthcdr 4 fp))
- (last-pos 0)
- (found 1)
- (order (and (nth 3 fp) (car (nth 3 fp))))
- (nocheck (append '("&optional" "&rest" "&key" "&aux"
- "&context" "&environment" "&whole"
- "&body" "&allow-other-keys" "nil")
- (nth 3 fp)))
+ (let* ((args (nthcdr 4 fp))
+ (this-arg (car args))
+ (this-arg (if (string-prefix-p ":" this-arg)
+ (substring this-arg 1)
+ this-arg))
+ (last-pos 0)
+ (found 1)
+ (order (and (nth 3 fp) (car (nth 3 fp))))
+ (nocheck (append '("&optional" "&rest" "&key" "&aux"
+ "&context" "&environment" "&whole"
+ "&body" "&allow-other-keys" "nil")
+ (nth 3 fp)))
(inopts nil))
(while (and args found (> found last-pos))
(if (or (member (car args) nocheck)
- (string-match "\\`_" (car args)))
+ (string-match "\\`_" this-arg))
(setq args (cdr args)
+ this-arg (if (string-prefix-p ":" (car args))
+ (substring (car args) 1)
+ (car args))
inopts t)
(setq last-pos found
found (save-excursion
(re-search-forward
- (concat "\\<" (upcase (car args))
+ (concat "\\<" (upcase this-arg)
;; Require whitespace OR
;; ITEMth<space> OR
;; ITEMs<space>
@@ -1791,7 +1798,7 @@ checkdoc-this-string-valid-engine
;; and see if the user wants to capitalize it.
(if (save-excursion
(re-search-forward
- (concat "\\<\\(" (car args)
+ (concat "\\<\\(" this-arg
;; Require whitespace OR
;; ITEMth<space> OR
;; ITEMs<space>
@@ -1801,10 +1808,15 @@ checkdoc-this-string-valid-engine
(match-beginning 1) (match-end 1)
(format-message
"If this is the argument `%s', it should appear as %s. Fix?"
- (car args) (upcase (car args)))
- (upcase (car args)) t)
+ this-arg (upcase this-arg))
+ (upcase this-args) t)
(setq found (match-beginning 1))))))
- (if found (setq args (cdr args)))))
+ (if found (setq args
+ (cdr args)
+ this-arg (if (string-prefix-p ":"
+ (car args))
+ (substring (car args) 1)
+ (car args))))))
(if (not found)
;; It wasn't found at all! Offer to attach this new symbol
;; to the end of the documentation string.
@@ -1817,7 +1829,7 @@ checkdoc-this-string-valid-engine
(goto-char e) (forward-char -1)
(insert "\n"
(if inopts "Optional a" "A")
- "rgument " (upcase (car args))
+ "rgument " (upcase this-arg)
" ")
(insert (read-string "Describe: "))
(if (not (save-excursion (forward-char -1)
@@ -1828,7 +1840,7 @@ checkdoc-this-string-valid-engine
(checkdoc-create-error
(format-message
"Argument `%s' should appear (as %s) in the doc string"
- (car args) (upcase (car args)))
+ (car args) (upcase this-arg))
s (marker-position e))))
(if (or (and order (eq order 'yes))
(and (not order) checkdoc-arguments-in-order-flag))
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78543
; Package
emacs
.
(Sat, 31 May 2025 15:06:01 GMT)
Full text and
rfc822 format available.
Message #11 received at 78543 <at> debbugs.gnu.org (full text, mbox):
>> ```
>> (cl-defun funky-keys (&key ((:this that) 42) &aux (the-beast 666))
>> "Do something with THAT (passed via :THIS)"
>> ...
>> )
>> ```
FWIW, I consider this `(:this that)` of CL's keyword args to be
a misfeature, so I'm happy for Emacs to behave suboptimally here, tho
I'd prefer for cl-lib to stop supporting it.
> Also, I believe that THE-BEAST should
> indeed be mentioned in the doc string.
Why? It's not part of the function's exposed interface.
It's just a weird way to define a local variable.
I also find this `&aux` thingy to be a misfeature in CL, which we
usually shouldn't support [ tho currently it's admittedly handy at
times in `cl-defstruct` constructors. ], so I'm not sure it's worth
complicating checkdoc for it.
Stefan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78543
; Package
emacs
.
(Sat, 31 May 2025 16:22:04 GMT)
Full text and
rfc822 format available.
Message #14 received at 78543 <at> debbugs.gnu.org (full text, mbox):
> From: Stefan Monnier <monnier <at> iro.umontreal.ca>
> Cc: Marco Antoniotti <marcoxa <at> gmail.com>, 78543 <at> debbugs.gnu.org
> Date: Sat, 31 May 2025 10:56:19 -0400
>
> >> ```
> >> (cl-defun funky-keys (&key ((:this that) 42) &aux (the-beast 666))
> >> "Do something with THAT (passed via :THIS)"
> >> ...
> >> )
> >> ```
>
> FWIW, I consider this `(:this that)` of CL's keyword args to be
> a misfeature, so I'm happy for Emacs to behave suboptimally here, tho
> I'd prefer for cl-lib to stop supporting it.
But do you have anything against the patch I proposed to install?
> > Also, I believe that THE-BEAST should
> > indeed be mentioned in the doc string.
>
> Why? It's not part of the function's exposed interface.
> It's just a weird way to define a local variable.
>
> I also find this `&aux` thingy to be a misfeature in CL, which we
> usually shouldn't support [ tho currently it's admittedly handy at
> times in `cl-defstruct` constructors. ], so I'm not sure it's worth
> complicating checkdoc for it.
I didn't suggest complicating checkdoc due to &aux arguments. So we
basically agree here.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78543
; Package
emacs
.
(Sat, 31 May 2025 16:36:02 GMT)
Full text and
rfc822 format available.
Message #17 received at 78543 <at> debbugs.gnu.org (full text, mbox):
>> FWIW, I consider this `(:this that)` of CL's keyword args to be
>> a misfeature, so I'm happy for Emacs to behave suboptimally here, tho
>> I'd prefer for cl-lib to stop supporting it.
> But do you have anything against the patch I proposed to install?
I don't like the extra code in your patch to handle this special case,
to be honest, but as long as we want to fully support this CL
functionality, your patch looks fine.
> I didn't suggest complicating checkdoc due to &aux arguments.
> So we basically agree here.
Indeed, we get to the same conclusion, tho via different paths. 🙂
Stefan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78543
; Package
emacs
.
(Sat, 31 May 2025 21:59:02 GMT)
Full text and
rfc822 format available.
Message #20 received at 78543 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Hi...
On Sat, May 31, 2025 at 1:07 PM Eli Zaretskii <eliz <at> gnu.org> wrote:
> > From: Marco Antoniotti <marcoxa <at> gmail.com>
> > Date: Wed, 21 May 2025 22:38:48 +0200
> >
> > The problem is with `checkdoc` not correctly handling some docstring
> > in `cl-lib` style declarations.
> >
> > I have a function like
> >
> > ```
> > (cl-defun funky-keys (&key ((:this that) 42) &aux (the-beast 666))
> > "Do something with THAT (passed via :THIS)"
> > ...
> > )
> > ```
> >
> > checkdoc insists on flagging :THIS and THE-BEAST as missing from the
> docstring.
> >
> > Another one is the following.
> >
> > ```
> > (cl-defgeneric gf (a s d f)
> > (:documentation "Munge A, S, D, and F."))
> > ```
> >
> > checkdoc does not recognize the :documentation option (which is valid
> according to cl-lib).
> >
> > This problem is still visible in 30.1
>
> Sigh. This is notoriously under-documented in the cl.info manual.
> After reading and re-reading the node "Argument Lists" there, I
> believe that we expect :this to be referenced as "THIS" (without the
> leading colon) in the doc string, since argument references in doc
> strings should be words, not symbols, and ':' is not a
> word-constituent character. Also, I believe that THE-BEAST should
> indeed be mentioned in the doc string. This:
>
> (cl-defun funky-keys (&key ((:this that) 42) &aux (the-beast 666))
> "Do something with THAT (passed via THIS), binding THE-BEAST to 666."
> nil
> )
>
> passes the checkdoc tests, if we install the simple patch below.
>
> But since I'm very far from being an expert of cl-defun and its
> correct usage, I invite CL experts to chime in and provide their
> opinions.
>
The problem shows up even if you use THIS without a colon (without the
patch, I mean).
THE-BEAST should NOT be flagged as it is definitively not part of the
function signature. &aux variables should be ignored for doc strings.
Any update on the cl-defgeneric :documentation slot?
My 2 cents: Yes Emacs Lisp should support CL idioms. CL got many things
right in the base language (yes Virginia! I know about pathnames :) ).
All the best
--
Marco Antoniotti
Somewhere over the Rainbow
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78543
; Package
emacs
.
(Sun, 01 Jun 2025 05:39:10 GMT)
Full text and
rfc822 format available.
Message #23 received at 78543 <at> debbugs.gnu.org (full text, mbox):
> From: Marco Antoniotti <marcoxa <at> gmail.com>
> Date: Sat, 31 May 2025 23:58:26 +0200
> Cc: Stefan Monnier <monnier <at> iro.umontreal.ca>, 78543 <at> debbugs.gnu.org
>
> (cl-defun funky-keys (&key ((:this that) 42) &aux (the-beast 666))
> "Do something with THAT (passed via THIS), binding THE-BEAST to 666."
> nil
> )
>
> passes the checkdoc tests, if we install the simple patch below.
>
> But since I'm very far from being an expert of cl-defun and its
> correct usage, I invite CL experts to chime in and provide their
> opinions.
>
> The problem shows up even if you use THIS without a colon (without the patch, I mean).
Yes, like I said. Does the patch fix it for you?
> THE-BEAST should NOT be flagged as it is definitively not part of the function signature. &aux variables
> should be ignored for doc strings.
I disagree. If they should be ignored, why use them at all? My
assumption is that if you use them, they are important, so should be
documented. The doc string is not only about the function's
signature, it's about anything that's important to know about the
function.
> Any update on the cl-defgeneric :documentation slot?
Is this related, or is this a separate issue? Do we have a separate
bug report for it?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78543
; Package
emacs
.
(Sun, 01 Jun 2025 07:53:06 GMT)
Full text and
rfc822 format available.
Message #26 received at 78543 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On Sun, Jun 1, 2025 at 7:38 AM Eli Zaretskii <eliz <at> gnu.org> wrote:
> > From: Marco Antoniotti <marcoxa <at> gmail.com>
> > Date: Sat, 31 May 2025 23:58:26 +0200
> > Cc: Stefan Monnier <monnier <at> iro.umontreal.ca>, 78543 <at> debbugs.gnu.org
> >
> > (cl-defun funky-keys (&key ((:this that) 42) &aux (the-beast 666))
> > "Do something with THAT (passed via THIS), binding THE-BEAST to
> 666."
> > nil
> > )
> >
> > passes the checkdoc tests, if we install the simple patch below.
> >
> > But since I'm very far from being an expert of cl-defun and its
> > correct usage, I invite CL experts to chime in and provide their
> > opinions.
> >
> > The problem shows up even if you use THIS without a colon (without the
> patch, I mean).
>
> Yes, like I said. Does the patch fix it for you?
>
I have not checked the patch. Sorry. I assume it works, although I am
inclined to allow :THIS in the doc string.
After all that is the signature of the function.
> THE-BEAST should NOT be flagged as it is definitively not part of the
> function signature. &aux variables
> > should be ignored for doc strings.
>
> I disagree. If they should be ignored, why use them at all? My
> assumption is that if you use them, they are important, so should be
> documented. The doc string is not only about the function's
> signature, it's about anything that's important to know about the
> function.
>
The assumption of the CL programmer (well, I believe most of them, all 42
of them) is that they are a convenience (with possible optimization
effects) mostly used to avoid a top level LET. If you go down that line of
thought then you may end up wanting checkdoc to do the following.
(cl-defun foo (x &aux (y (+ 42 x))
"Use X and Y. But, `checkdoc' forces me to tell you about THE-ANSWER."
(let ((the-answer (- y x)))
....
))
That is why &aux should be ignored by checkdoc.
> Any update on the cl-defgeneric :documentation slot?
>
> Is this related, or is this a separate issue? Do we have a separate
> bug report for it?
>
Same bug report a bit below the &key/&aux lambda list issue.
Cheers
--
Marco Antoniotti
Somewhere over the Rainbow
[Message part 2 (text/html, inline)]
Reply sent
to
Eli Zaretskii <eliz <at> gnu.org>
:
You have taken responsibility.
(Sat, 07 Jun 2025 09:19:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Marco Antoniotti <marcoxa <at> gmail.com>
:
bug acknowledged by developer.
(Sat, 07 Jun 2025 09:19:02 GMT)
Full text and
rfc822 format available.
Message #31 received at 78543-done <at> debbugs.gnu.org (full text, mbox):
> From: Marco Antoniotti <marcoxa <at> gmail.com>
> Date: Sun, 1 Jun 2025 09:52:11 +0200
> Cc: monnier <at> iro.umontreal.ca, 78543 <at> debbugs.gnu.org
>
> On Sun, Jun 1, 2025 at 7:38 AM Eli Zaretskii <eliz <at> gnu.org> wrote:
>
> > From: Marco Antoniotti <marcoxa <at> gmail.com>
> > Date: Sat, 31 May 2025 23:58:26 +0200
> > Cc: Stefan Monnier <monnier <at> iro.umontreal.ca>, 78543 <at> debbugs.gnu.org
> >
> > (cl-defun funky-keys (&key ((:this that) 42) &aux (the-beast 666))
> > "Do something with THAT (passed via THIS), binding THE-BEAST to 666."
> > nil
> > )
> >
> > passes the checkdoc tests, if we install the simple patch below.
> >
> > But since I'm very far from being an expert of cl-defun and its
> > correct usage, I invite CL experts to chime in and provide their
> > opinions.
> >
> > The problem shows up even if you use THIS without a colon (without the patch, I mean).
>
> Yes, like I said. Does the patch fix it for you?
>
> I have not checked the patch. Sorry. I assume it works, although I am inclined to allow :THIS in the doc
> string.
> After all that is the signature of the function.
>
> > THE-BEAST should NOT be flagged as it is definitively not part of the function signature. &aux
> variables
> > should be ignored for doc strings.
>
> I disagree. If they should be ignored, why use them at all? My
> assumption is that if you use them, they are important, so should be
> documented. The doc string is not only about the function's
> signature, it's about anything that's important to know about the
> function.
>
> The assumption of the CL programmer (well, I believe most of them, all 42 of them) is that they are a
> convenience (with possible optimization
> effects) mostly used to avoid a top level LET. If you go down that line of thought then you may end up
> wanting checkdoc to do the following.
>
> (cl-defun foo (x &aux (y (+ 42 x))
> "Use X and Y. But, `checkdoc' forces me to tell you about THE-ANSWER."
> (let ((the-answer (- y x)))
> ....
> ))
>
> That is why &aux should be ignored by checkdoc.
Thanks, but I don't think I agree.
I've now installed the patch I proposed up-thread, and I'm closing
this bug.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78543
; Package
emacs
.
(Sat, 07 Jun 2025 09:55:01 GMT)
Full text and
rfc822 format available.
Message #34 received at 78543-done <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Hi
you mean you are willing to go against the collective will of the CL
Community at large? 🥹😏😁😑
On Sat, Jun 7, 2025 at 11:18 AM Eli Zaretskii <eliz <at> gnu.org> wrote:
> > From: Marco Antoniotti <marcoxa <at> gmail.com>
> > Date: Sun, 1 Jun 2025 09:52:11 +0200
> > Cc: monnier <at> iro.umontreal.ca, 78543 <at> debbugs.gnu.org
> >
> > On Sun, Jun 1, 2025 at 7:38 AM Eli Zaretskii <eliz <at> gnu.org> wrote:
> >
> > > From: Marco Antoniotti <marcoxa <at> gmail.com>
> > > Date: Sat, 31 May 2025 23:58:26 +0200
> > > Cc: Stefan Monnier <monnier <at> iro.umontreal.ca>, 78543 <at> debbugs.gnu.org
> > >
> > > (cl-defun funky-keys (&key ((:this that) 42) &aux (the-beast 666))
> > > "Do something with THAT (passed via THIS), binding THE-BEAST
> to 666."
> > > nil
> > > )
> > >
> > > passes the checkdoc tests, if we install the simple patch below.
> > >
> > > But since I'm very far from being an expert of cl-defun and its
> > > correct usage, I invite CL experts to chime in and provide their
> > > opinions.
> > >
> > > The problem shows up even if you use THIS without a colon (without
> the patch, I mean).
> >
> > Yes, like I said. Does the patch fix it for you?
> >
> > I have not checked the patch. Sorry. I assume it works, although I am
> inclined to allow :THIS in the doc
> > string.
> > After all that is the signature of the function.
> >
> > > THE-BEAST should NOT be flagged as it is definitively not part of the
> function signature. &aux
> > variables
> > > should be ignored for doc strings.
> >
> > I disagree. If they should be ignored, why use them at all? My
> > assumption is that if you use them, they are important, so should be
> > documented. The doc string is not only about the function's
> > signature, it's about anything that's important to know about the
> > function.
> >
> > The assumption of the CL programmer (well, I believe most of them, all
> 42 of them) is that they are a
> > convenience (with possible optimization
> > effects) mostly used to avoid a top level LET. If you go down that line
> of thought then you may end up
> > wanting checkdoc to do the following.
> >
> > (cl-defun foo (x &aux (y (+ 42 x))
> > "Use X and Y. But, `checkdoc' forces me to tell you about
> THE-ANSWER."
> > (let ((the-answer (- y x)))
> > ....
> > ))
> >
> > That is why &aux should be ignored by checkdoc.
>
> Thanks, but I don't think I agree.
>
> I've now installed the patch I proposed up-thread, and I'm closing
> this bug.
>
--
Marco Antoniotti
Somewhere over the Rainbow
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78543
; Package
emacs
.
(Sun, 08 Jun 2025 04:24:01 GMT)
Full text and
rfc822 format available.
Message #37 received at submit <at> debbugs.gnu.org (full text, mbox):
Marco Antoniotti <marcoxa <at> gmail.com> writes:
> you mean you are willing to go against the collective will of the CL Community
> at large? 🥹😏😁😑
If the checkdoc nagging motivates someone to replace an &aux binding
with a let form, I'd count that as an overall win. ;)
This bug report was last modified 11 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.