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

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Severity: minor; Reported by: Jonas Bernoulli <jonas@HIDDEN>; dated Mon, 24 Feb 2025 18:28:01 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.
Severity set to 'minor' from 'normal' Request was from Stefan Kangas <stefankangas@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 76528 <at> debbugs.gnu.org:


Received: (at 76528) by debbugs.gnu.org; 24 Feb 2025 20:42:27 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Feb 24 15:42:27 2025
Received: from localhost ([127.0.0.1]:42941 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tmfHW-0001I0-UO
	for submit <at> debbugs.gnu.org; Mon, 24 Feb 2025 15:42:27 -0500
Received: from mail.hostpark.net ([212.243.197.30]:43594)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <jonas@HIDDEN>) id 1tmfHU-0001Hl-8f
 for 76528 <at> debbugs.gnu.org; Mon, 24 Feb 2025 15:42:25 -0500
Received: from localhost (localhost [127.0.0.1])
 by mail.hostpark.net (Postfix) with ESMTP id AC25A164AE;
 Mon, 24 Feb 2025 21:42:21 +0100 (CET)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=bernoul.li; h=
 content-type:content-type:mime-version:message-id:date:date
 :references:in-reply-to:subject:subject:from:from; s=sel2011a;
 t=1740429741; bh=stl5uaROBUvrTRbBU507qJ/da0UssU3FWWCA2bMj5yE=; b=
 Su2iu6HatidA2W/hM8MNh9QFB7iCyBR7w42MBcObiUb9VmHD+SF8cO0ypYrRUwS/
 GSGW+GvjCbB4hUApMCYi7Qeo7dXkHSBUF40BO1pfdaCavOpveXmS6dBPEok+buHG
 2gfdeGVQjyawGQ7ZIv4DzO8B8gEIzskv0tQzpBxZ428=
X-Virus-Scanned: by Hostpark/NetZone Mailprotection at hostpark.net
Received: from mail.hostpark.net ([127.0.0.1])
 by localhost (mail0.hostpark.net [127.0.0.1]) (amavisd-new, port 10224)
 with ESMTP id eQ5VCexXqPvf; Mon, 24 Feb 2025 21:42:21 +0100 (CET)
Received: from customer (localhost [127.0.0.1])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange ECDHE (prime256v1) server-signature RSA-PSS (2048 bits)
 server-digest SHA256) (No client certificate requested)
 by mail.hostpark.net (Postfix) with ESMTPSA id EA2A416466;
 Mon, 24 Feb 2025 21:42:20 +0100 (CET)
From: Jonas Bernoulli <jonas@HIDDEN>
To: Stefan Monnier <monnier@HIDDEN>, Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#76528: 30; Advising functions can cause docstring to be lost
In-Reply-To: <jwvzfibi0ti.fsf-monnier+emacs@HIDDEN>
References: <874j0jjj33.fsf@HIDDEN> <86r03nxi8l.fsf@HIDDEN>
 <jwvzfibi0ti.fsf-monnier+emacs@HIDDEN>
Date: Mon, 24 Feb 2025 21:42:20 +0100
Message-ID: <87cyf76pn7.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 76528
Cc: 76528 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

Stefan Monnier <monnier@HIDDEN> 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)))




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#76528; Package emacs. Full text available.

Message received at 76528 <at> debbugs.gnu.org:


Received: (at 76528) by debbugs.gnu.org; 24 Feb 2025 19:48:20 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Feb 24 14:48:20 2025
Received: from localhost ([127.0.0.1]:42787 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tmeRA-0006xW-4m
	for submit <at> debbugs.gnu.org; Mon, 24 Feb 2025 14:48:20 -0500
Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:50111)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <monnier@HIDDEN>)
 id 1tmeR7-0006xH-Nk
 for 76528 <at> debbugs.gnu.org; Mon, 24 Feb 2025 14:48:18 -0500
Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1])
 by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id ABEE1442BE3;
 Mon, 24 Feb 2025 14:48:11 -0500 (EST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca;
 s=mail; t=1740426490;
 bh=pdBhwja4yqHptawzwwMrGPsLzUSlFOYL6sBSyDDZ6L4=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date:From;
 b=CregEwDhoFbYz31E27Qb+BB4O70qhYpw/mMchrhwqx8DZr5vMJmcWhw1NOyqDWtUP
 APfDWWxd9FvPYeZgfk7eIX7RbkCSj1g6PqtKgHVH95g9+p6apB5dJ+EJiCvk6zQ20Y
 lLWayumMk9Qv4f0MKIF5Bgw5gHVNf0AaB/0RJISPhLGyhPow35scj/Vp8E303GD+wt
 1vJVcz30/3iUA6zDMo14KUg5Oc9KW1fsE1T6py/sllV6nmc/BXd0ife+sigtLjnrqp
 x0PScuu+CYlD/tbd6gMjCFGFS264NXFzfSDfh/qO/73KVJNPxbpT84T0AEPEsp+3ju
 tatuyemBsbt2Q==
Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1])
 by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id D0BEF442BD9;
 Mon, 24 Feb 2025 14:48:10 -0500 (EST)
Received: from alfajor (unknown [104.247.242.5])
 by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 9E5DF120422;
 Mon, 24 Feb 2025 14:48:10 -0500 (EST)
From: Stefan Monnier <monnier@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#76528: 30; Advising functions can cause docstring to be lost
In-Reply-To: <86r03nxi8l.fsf@HIDDEN>
Message-ID: <jwvzfibi0ti.fsf-monnier+emacs@HIDDEN>
References: <874j0jjj33.fsf@HIDDEN> <86r03nxi8l.fsf@HIDDEN>
Date: Mon, 24 Feb 2025 14:48:09 -0500
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain
X-SPAM-INFO: Spam detection results:  0
 ALL_TRUSTED                -1 Passed through trusted hosts only via SMTP
 AWL -0.398 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DKIM_SIGNED               0.1 Message has a DKIM or DK signature,
 not necessarily valid
 DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature
 DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's
 domain
 DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from
 domain
X-SPAM-LEVEL: 
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 76528
Cc: Jonas Bernoulli <jonas@HIDDEN>, 76528 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> 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))


- Stefan





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#76528; Package emacs. Full text available.

Message received at 76528 <at> debbugs.gnu.org:


Received: (at 76528) by debbugs.gnu.org; 24 Feb 2025 19:20:23 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Feb 24 14:20:23 2025
Received: from localhost ([127.0.0.1]:42688 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tme07-0005bJ-BK
	for submit <at> debbugs.gnu.org; Mon, 24 Feb 2025 14:20:23 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:59978)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1tme05-0005aw-R4
 for 76528 <at> debbugs.gnu.org; Mon, 24 Feb 2025 14:20:22 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1tmdzy-0007tW-8c; Mon, 24 Feb 2025 14:20:14 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=EAvOuTT2eU5mb0WEQriZRZrNHAFYKQ1SH0ED/m9v9YE=; b=E9UvTEB+LodW
 nAZmzOi3m9CLotcCFLp5YCQ+t9druiLf1YuWYDu2P+PD89ARxbr0IxnuYHmBErJmj8qNbJRu3UwuA
 4RS6+RdZn+gJjHh5n3Ou74g1GkMd2RHYodgdXl2uwWzrS/927oUCdWxmpWkg73dzaqHBwP3Dn8ju2
 Z8mdrRJVTeA3le9Uwe+Ra2X/I3/XApFBK1NlVM5Zlaw3Ynh38GpQ+aDRtjHnRx6sDAmBUBHrTIKfo
 R2SE3oRXhOIafduh6TyZrWe3PIyV1A5CF/gTUcJ69lYL7lUQbl6cGo9+SYkwRXsOQSRinI5hTFtqD
 Sp2GpoJJS9+q1IWpvNbgmg==;
Date: Mon, 24 Feb 2025 21:20:10 +0200
Message-Id: <86r03nxi8l.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Jonas Bernoulli <jonas@HIDDEN>,
 Stefan Monnier <monnier@HIDDEN>
In-Reply-To: <874j0jjj33.fsf@HIDDEN> (bug-gnu-emacs@HIDDEN)
Subject: Re: bug#76528: 30; Advising functions can cause docstring to be lost
References: <874j0jjj33.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 76528
Cc: 76528 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> Date: Mon, 24 Feb 2025 19:25:36 +0100
> From:  Jonas Bernoulli via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs@HIDDEN>
> 
> Hello,
> 
> Depending on where the docstring is stored, advising a function can
> cause its original docstring to be lost.  This also affects 29.4 at
> least.
> 
> (defun embeded-docstr () "embeded docstr" nil)
> 
> (defun property-docstr () nil)
> (put 'property-docstr 'function-documentation "property docstr")
> 
> (defalias 'alias-docstr 'identity "alias docstr")
> 
> (defun maybe-loose-docstring (symbol)
>   (let ((a (documentation symbol))
>         (b nil)
>         (advice (lambda (fn &rest args) (apply fn args))))
>     (advice-add symbol :around advice)
>     (setq b (documentation symbol))
>     (advice-remove symbol advice)
>     `((,a) (,b) (,(documentation symbol)))))
> 
> (maybe-loose-docstring 'embeded-docstr)
> => (("embeded docstr\n\n(fn)")
>     ("embeded docstr\n\nThis function has :around advice: No documentation\n\n(fn)")
>     ("embeded docstr\n\n(fn)"))
> 
> (maybe-loose-docstring 'property-docstr)
> => (("property docstr")
>     ("\nThis function has :around advice: No documentation\n\n(fn)")
>     ("\n\n(fn)"))
> 
> (maybe-loose-docstring 'alias-docstr)
> => (("alias docstr")
>     ("Return the ARGUMENT unchanged.\n\nThis function has :around advice: No documentation\n\n(fn ARGUMENT)")
>     ("Return the ARGUMENT unchanged.\n\n(fn ARGUMENT)"))

Stefan, any comments?




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#76528; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 24 Feb 2025 18:27:05 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Feb 24 13:27:05 2025
Received: from localhost ([127.0.0.1]:42537 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tmdAX-0008BM-8g
	for submit <at> debbugs.gnu.org; Mon, 24 Feb 2025 13:27:05 -0500
Received: from lists.gnu.org ([2001:470:142::17]:43286)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <jonas@HIDDEN>) id 1tmdAT-00089W-Mf
 for submit <at> debbugs.gnu.org; Mon, 24 Feb 2025 13:27:02 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <jonas@HIDDEN>) id 1tmd9L-0003AI-S4
 for bug-gnu-emacs@HIDDEN; Mon, 24 Feb 2025 13:25:53 -0500
Received: from mail.hostpark.net ([212.243.197.30])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <jonas@HIDDEN>) id 1tmd9J-00023j-44
 for bug-gnu-emacs@HIDDEN; Mon, 24 Feb 2025 13:25:51 -0500
Received: from localhost (localhost [127.0.0.1])
 by mail.hostpark.net (Postfix) with ESMTP id BDBCE164CE
 for <bug-gnu-emacs@HIDDEN>; Mon, 24 Feb 2025 19:25:39 +0100 (CET)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=bernoul.li; h=
 content-type:content-type:mime-version:message-id:date:date
 :subject:subject:from:from; s=sel2011a; t=1740421539; bh=nP+GQIa
 OdMkj2PZ49dbDC7H4JnPYNyQNyAnXhVFp7w8=; b=11APIcHPwzYV0jnkYc+bTkg
 Hq8CKhhH7aCV/Vv4I9ZgjSgWJZ2kscqmlA/DFMhy3Rov49RNk+hvMYys88D86V+j
 UL6ZpN+pN0hDS2PZSeAGRCVGGRpjGautQ6AMMvWfkO7mcmNM9DnQtVf6824vpyPB
 tuf0QCDkD17rt0mRnG5A=
X-Virus-Scanned: by Hostpark/NetZone Mailprotection at hostpark.net
Received: from mail.hostpark.net ([127.0.0.1])
 by localhost (mail0.hostpark.net [127.0.0.1]) (amavisd-new, port 10224)
 with ESMTP id IUnNxBvaNgr8 for <bug-gnu-emacs@HIDDEN>;
 Mon, 24 Feb 2025 19:25:39 +0100 (CET)
Received: from customer (localhost [127.0.0.1])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange ECDHE (prime256v1) server-signature RSA-PSS (2048 bits)
 server-digest SHA256) (No client certificate requested)
 by mail.hostpark.net (Postfix) with ESMTPSA id 7604616466
 for <bug-gnu-emacs@HIDDEN>; Mon, 24 Feb 2025 19:25:39 +0100 (CET)
From: Jonas Bernoulli <jonas@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: 30; Advising functions can cause docstring to be lost
Date: Mon, 24 Feb 2025 19:25:36 +0100
Message-ID: <874j0jjj33.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
Received-SPF: pass client-ip=212.243.197.30; envelope-from=jonas@HIDDEN;
 helo=mail.hostpark.net
X-Spam_score_int: -27
X-Spam_score: -2.8
X-Spam_bar: --
X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
 RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001,
 RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001,
 SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 0.9 (/)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.1 (/)

Hello,

Depending on where the docstring is stored, advising a function can
cause its original docstring to be lost.  This also affects 29.4 at
least.

(defun embeded-docstr () "embeded docstr" nil)

(defun property-docstr () nil)
(put 'property-docstr 'function-documentation "property docstr")

(defalias 'alias-docstr 'identity "alias docstr")

(defun maybe-loose-docstring (symbol)
  (let ((a (documentation symbol))
        (b nil)
        (advice (lambda (fn &rest args) (apply fn args))))
    (advice-add symbol :around advice)
    (setq b (documentation symbol))
    (advice-remove symbol advice)
    `((,a) (,b) (,(documentation symbol)))))

(maybe-loose-docstring 'embeded-docstr)
=> (("embeded docstr\n\n(fn)")
    ("embeded docstr\n\nThis function has :around advice: No documentation\n\n(fn)")
    ("embeded docstr\n\n(fn)"))

(maybe-loose-docstring 'property-docstr)
=> (("property docstr")
    ("\nThis function has :around advice: No documentation\n\n(fn)")
    ("\n\n(fn)"))

(maybe-loose-docstring 'alias-docstr)
=> (("alias docstr")
    ("Return the ARGUMENT unchanged.\n\nThis function has :around advice: No documentation\n\n(fn ARGUMENT)")
    ("Return the ARGUMENT unchanged.\n\n(fn ARGUMENT)"))

Best regards,
Jonas




Acknowledgement sent to Jonas Bernoulli <jonas@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#76528; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Mon, 24 Feb 2025 22:00:03 UTC

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