Subject: Re: bug#76528: 30; Advising functions can cause docstring to be lost

From: Jonas Bernoulli <[email-masked]>
Date: Wed, 26 Feb 2025 17:12:25 +0100

> That sounds about right, tho you'd have to replace the `(documentation
> this-command)` with `(get this-command 'function-documentation)`.

I've decided to instead of destroying and resurrecting the doc-string,
I'm just not gonna destroy it.  ;P

I.e., to switch from advice-add to add-function.  I had somehow
convinced myself before that this does not work, but I must have
been holding it wrong.

(I still have to test it a bit more before pushing to main.)

This also (and really more importantly) helps with:

> Somewhat related question: can it happen that the command (stored in
> `this-command`, apparently) is not a symbol, and if so how do you
> wrap it?

It cannot happen for suffixes, those are always accessed via symbols.

But some menus do not disallow invocation of non-suffixes (commands
bound in other active keymaps).  If such a command is not accessed via
a symbol, then it wasn't properly wrapped before.  This could in rare
cases lead to a menu getting "stuck", which, while unfortunate, was easy
to fix (just invoke any menu).  Of course its better if this can never
happen, and I believe that by switching to add-function I have achieves
that.

     Cheers,
     Jonas