GNU bug report logs - #76528
30; Advising functions can cause docstring to be lost

Previous Next

Package: emacs;

Reported by: Jonas Bernoulli <jonas <at> bernoul.li>

Date: Mon, 24 Feb 2025 18:28:01 UTC

Severity: minor

Full log


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

From: Jonas Bernoulli <jonas <at> bernoul.li>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>, Eli Zaretskii <eliz <at> gnu.org>
Cc: 76528 <at> debbugs.gnu.org
Subject: Re: bug#76528: 30; Advising functions can cause docstring to be lost
Date: Mon, 24 Feb 2025 21:42:20 +0100
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:

>> Stefan, any comments?
>
> Just that it's directly related to this part of the code in
> `nadvice.el`:
>
>     ;; FIXME: We could use a defmethod on `function-documentation' instead,
>     ;; except when (autoloadp nf)!
>     (put symbol 'function-documentation `(advice--make-docstring ',symbol))

Transient (transient--wrap-command) has to advise every command that is
invoked while the menu is active, so this has the potential to cause a
lot of damage.  How should I deal with that?  Maybe essentially?:

  (let ((docstr (documentation this-command))
        (advice (lambda (fn &rest args) (apply fn args))))
    (advice-add this-command :around advice)
    (advice-remove this-command advice)
    (unless (equal (documentation this-command) docstr)
      (put this-command 'function-documentation docstr)))




This bug report was last modified 110 days ago.

Previous Next


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