GNU bug report logs - #59379
29.0.50; `define-advice' documentation needs improving

Previous Next

Package: emacs;

Reported by: Stefan Kangas <stefankangas <at> gmail.com>

Date: Sat, 19 Nov 2022 07:27:02 UTC

Severity: normal

Found in version 29.0.50

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


Message #8 received at 59379 <at> debbugs.gnu.org (full text, mbox):

From: Visuwesh <visuweshm <at> gmail.com>
To: Stefan Kangas <stefankangas <at> gmail.com>
Cc: 59379 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#59379: 29.0.50; `define-advice' documentation needs improving
Date: Sat, 19 Nov 2022 17:53:20 +0530
[வெள்ளி நவம்பர் 18, 2022] Stefan Kangas wrote:

> This bug report is about the documentation of the `define-advice' macro.
>
> [...]
>
> 3. This is its argument list:
>
>    (define-advice SYMBOL (HOW LAMBDA-LIST &optional NAME DEPTH) &rest
>    BODY)
>
>    The HOW, LAMBDA-LIST, NAME, DEPTH parameters are not documented in
>    the docstring, nor in the info manual.

HOW, LAMBDA-LIST, NAME, and DEPTH arguments become clear when once looks
up the add-function docstring, and the docstring already mentions
add-function.

> 4. There also seem to be a mistake (or merely a typo) in the argument
>    list as described in the argument list (note that "HOW" above is
>    replaced with "where"):
>
>     -- Macro: define-advice symbol (where lambda-list &optional name depth)
>              &rest body

IIRC, Stefan prefers HOW over WHERE since add-function has :filter-args
and friends.

> 5. The documentation of NAME says that: "The advice is an anonymous
>    function if NAME is ‘nil’ or a function named ‘symbol <at> name’."
>
>    I struggle with parsing this sentence.  It sounds like it is saying
>    that, if I want an anonymous function, I should define a function
>    named `symbol <at> name' (substituting `symbol' and `name') and then pass
>    that argument as the NAME argument?  But then the function is not
>    anonymous?

Would a comma help before the "or"? i.e.,

    The advice is an anonymous function if NAME is ‘nil’, or a function
    named ‘symbol <at> name’.

Changing symbol <at> name to SYMBOL <at> NAME like in the docstring will make it
clearer, I think.  If still not clear, the following happens in the case
of NAME being nil vs. non-nil

    NAME nil ==> (advice-add SYMBOL HOW (lambda LAMBDA-LIST BODY) ...)
    NAME non-nil ==> (advice-add SYMBOL HOW (defun SYMBOL <at> NAME LAMBDA-LIST BODY) ...)

HTH.




This bug report was last modified 1 year and 161 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.