From unknown Mon Jun 16 23:46:59 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#76528 <76528@debbugs.gnu.org> To: bug#76528 <76528@debbugs.gnu.org> Subject: Status: 30; Advising functions can cause docstring to be lost Reply-To: bug#76528 <76528@debbugs.gnu.org> Date: Tue, 17 Jun 2025 06:46:59 +0000 retitle 76528 30; Advising functions can cause docstring to be lost reassign 76528 emacs submitter 76528 Jonas Bernoulli severity 76528 minor thanks From debbugs-submit-bounces@debbugs.gnu.org Mon Feb 24 13:27:05 2025 Received: (at submit) by debbugs.gnu.org; 24 Feb 2025 18:27:05 +0000 Received: from localhost ([127.0.0.1]:42537 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tmdAX-0008BM-8g for submit@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 ) id 1tmdAT-00089W-Mf for submit@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 ) id 1tmd9L-0003AI-S4 for bug-gnu-emacs@gnu.org; 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 ) id 1tmd9J-00023j-44 for bug-gnu-emacs@gnu.org; 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 ; 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 ; 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 ; Mon, 24 Feb 2025 19:25:39 +0100 (CET) From: Jonas Bernoulli To: bug-gnu-emacs@gnu.org Subject: 30; Advising functions can cause docstring to be lost Date: Mon, 24 Feb 2025 19:25:36 +0100 Message-ID: <874j0jjj33.fsf@bernoul.li> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=212.243.197.30; envelope-from=jonas@bernoul.li; 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@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" 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 From debbugs-submit-bounces@debbugs.gnu.org Mon Feb 24 14:20:23 2025 Received: (at 76528) by debbugs.gnu.org; 24 Feb 2025 19:20:23 +0000 Received: from localhost ([127.0.0.1]:42688 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tme07-0005bJ-BK for submit@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 ) id 1tme05-0005aw-R4 for 76528@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 ) 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@gnu.org> From: Eli Zaretskii To: Jonas Bernoulli , Stefan Monnier In-Reply-To: <874j0jjj33.fsf@bernoul.li> (bug-gnu-emacs@gnu.org) Subject: Re: bug#76528: 30; Advising functions can cause docstring to be lost References: <874j0jjj33.fsf@bernoul.li> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 76528 Cc: 76528@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" 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" > > 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? From debbugs-submit-bounces@debbugs.gnu.org Mon Feb 24 14:48:20 2025 Received: (at 76528) by debbugs.gnu.org; 24 Feb 2025 19:48:20 +0000 Received: from localhost ([127.0.0.1]:42787 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tmeRA-0006xW-4m for submit@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 ) id 1tmeR7-0006xH-Nk for 76528@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 To: Eli Zaretskii Subject: Re: bug#76528: 30; Advising functions can cause docstring to be lost In-Reply-To: <86r03nxi8l.fsf@gnu.org> Message-ID: References: <874j0jjj33.fsf@bernoul.li> <86r03nxi8l.fsf@gnu.org> 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 , 76528@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" 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 From debbugs-submit-bounces@debbugs.gnu.org Mon Feb 24 15:42:27 2025 Received: (at 76528) by debbugs.gnu.org; 24 Feb 2025 20:42:27 +0000 Received: from localhost ([127.0.0.1]:42941 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tmfHW-0001I0-UO for submit@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 ) id 1tmfHU-0001Hl-8f for 76528@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 To: Stefan Monnier , Eli Zaretskii Subject: Re: bug#76528: 30; Advising functions can cause docstring to be lost In-Reply-To: References: <874j0jjj33.fsf@bernoul.li> <86r03nxi8l.fsf@gnu.org> Date: Mon, 24 Feb 2025 21:42:20 +0100 Message-ID: <87cyf76pn7.fsf@bernoul.li> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 76528 Cc: 76528@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) Stefan Monnier 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))) From debbugs-submit-bounces@debbugs.gnu.org Mon Feb 24 16:49:16 2025 Received: (at control) by debbugs.gnu.org; 24 Feb 2025 21:49:16 +0000 Received: from localhost ([127.0.0.1]:43105 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tmgKC-0002Lk-6H for submit@debbugs.gnu.org; Mon, 24 Feb 2025 16:49:16 -0500 Received: from mail-ed1-x52f.google.com ([2a00:1450:4864:20::52f]:61772) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1tmgJy-0002KH-P5 for control@debbugs.gnu.org; Mon, 24 Feb 2025 16:49:03 -0500 Received: by mail-ed1-x52f.google.com with SMTP id 4fb4d7f45d1cf-5e0505275b7so7949556a12.3 for ; Mon, 24 Feb 2025 13:49:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1740433736; x=1741038536; darn=debbugs.gnu.org; h=to:subject:message-id:date:mime-version:from:from:to:cc:subject :date:message-id:reply-to; bh=EZOEvCgKDKNPNxWIkdUnbZIKtn42ko85/xvmIZ21Ukk=; b=MViLuSzHjMikkuX4uxVSTlx54rOMiBh1C2xNCANB/dMT5sX7HS50RN07+6jBwApZ/m bNHh3hiTZz3kmoy8MxOuuxmXjyb1PGxu0e9rrybpIqaVjZoXtC5onvgUMb+bTecw8CAz FE22EPyKZDoq+RAyxa1iGQu9c6x29hAikqQx6uaBgGnY+AcjIONMYZ2efOCnV3gA3Qmt Dk/oJl+gacVHByTTSj84HTtPddSOxDvP2VD6rtgfY15LiaG8GZhsVuKvgJNHKY+Bl7Er hxTn7OAf2SjUf2F6lgBP785UlySwGD5BdKrollrwhKI04zrXhKlEns6krWiRpepXTcRB CxUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740433736; x=1741038536; h=to:subject:message-id:date:mime-version:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=EZOEvCgKDKNPNxWIkdUnbZIKtn42ko85/xvmIZ21Ukk=; b=ttKKoElMV4sKBkiQtSAqHztx4ttgF1aoGtgTIXZXXcKVxZrDRAS7xjA/Oqrp/y8SpT PI9nQv6JnS2/iw+tZW85w25Heu4Y3fZrIhry5oydw1a2LMtpLek6B/ejyUnJjGPa8bIZ 4NnV10RIhzuRZDB+VOrCiDv9YDetD3Hwz+mz2soBc0tbx1+8wD95gvYh/WZYuSG1imTH 2NjAPP3WQ8acXmd1NaD14HTwNVqLGy9BQm4etajST0zn4UoeKK6ETWmitGERReblInIR PZiNivyqwzlYlTmBbTAh9OvAGvAHnMnX3Ix1lYlw2ooIfIJRJVeEU31h5hN5nsQubrup 9Oiw== X-Gm-Message-State: AOJu0YwvXv9i4CGYCvwTxjjA0a5Wc7aJoE9qGjGaHclP4AWinBdH7laz ICKREfJBPs3Vv4p2VnymchFAfpEEKtT+/i7kFkDSGTOjoYncWs1qQ/CdaLl2H29pnjDc/szNXlo i8YIluUaZabT2G0mdGqanBK4SNIBgPhlD494= X-Gm-Gg: ASbGncsJcHRbOlnN9qnFd33XOiMRy9zT463dq3wnQoaONzWws5UBocQd4ev0mxaS0g0 WoxbmzfQi+mreR5oHHBjU063aFlbr6+daRA0q2Sj1ANHE5NJ1UAXFLl1gEO13dIgwqxnR4AMqx1 Qq+LbFedySgA== X-Google-Smtp-Source: AGHT+IH+gSRgT8VQfscBS8yw4nwcCF3fK+u+9eiyG+TV9MpHtI7+LVpUM1n65wKSBcLqozyO+eCHW4s/G/lHXRgL2qE= X-Received: by 2002:a05:6402:2682:b0:5de:dd31:1fad with SMTP id 4fb4d7f45d1cf-5e0b70cd051mr14905233a12.6.1740433736529; Mon, 24 Feb 2025 13:48:56 -0800 (PST) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Mon, 24 Feb 2025 21:48:55 +0000 From: Stefan Kangas MIME-Version: 1.0 Date: Mon, 24 Feb 2025 21:48:55 +0000 X-Gm-Features: AWEUYZkPTzKiUVzvOVuFC28ZWY0fCrpsLaAuuuPMPp8vBMdwjJUHpIn1dUrgA_U Message-ID: Subject: control message for bug #76528 To: control@debbugs.gnu.org Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) severity 76528 minor quit From debbugs-submit-bounces@debbugs.gnu.org Tue Feb 25 15:38:20 2025 Received: (at 76528) by debbugs.gnu.org; 25 Feb 2025 20:38:20 +0000 Received: from localhost ([127.0.0.1]:48665 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tn1h6-0000fz-1q for submit@debbugs.gnu.org; Tue, 25 Feb 2025 15:38:20 -0500 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:18135) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tn1h2-0000fh-MJ for 76528@debbugs.gnu.org; Tue, 25 Feb 2025 15:38:18 -0500 Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 1634F80848; Tue, 25 Feb 2025 15:38:11 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1740515890; bh=lC7946n4ZRyn3FGpon0xyWSN9VfmwALF4l2tHYbloNc=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=L+1ijF38nlkH+TLRrWt+0dT0EtC1M8ZlZ8wHmJzbHBaWpcJRLIs9PY7T6kEgrFJkX Uz5CDxmrpb/uSoIP8Styh5oJSguxH+pn3Wd21Ba4JzxXHmCh4zL8JbtSuO0HzV+JCE yG/4JVyz+Q9zbkeJwv4KGgCrkpXTnqowkj3fl4vQj8XhiCmQbAV9IQWB7BjXwyUZeR aeHGX7gCR/jcWqU4sKZJWf7pEOFeTnORtnpwgR+/q874JtyWAp5wgjQ4Qpos45o3Yw /Zw+HoCWEP5jbQ3V1VKSnjvX17jN9j9fUgnHBY1JaG/oLGh1D0gWE0EO6LGA8YNC80 2dZfm3F56BEwQ== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 340998025B; Tue, 25 Feb 2025 15:38:10 -0500 (EST) Received: from pastel (unknown [104.247.242.5]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 04D1B120342; Tue, 25 Feb 2025 15:38:09 -0500 (EST) From: Stefan Monnier To: Jonas Bernoulli Subject: Re: bug#76528: 30; Advising functions can cause docstring to be lost In-Reply-To: <87cyf76pn7.fsf@bernoul.li> (Jonas Bernoulli's message of "Mon, 24 Feb 2025 21:42:20 +0100") Message-ID: References: <874j0jjj33.fsf@bernoul.li> <86r03nxi8l.fsf@gnu.org> <87cyf76pn7.fsf@bernoul.li> Date: Tue, 25 Feb 2025 15:38:09 -0500 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.208 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: Eli Zaretskii , 76528@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" 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' inste= ad, >> ;; except when (autoloadp nf)! >> (put symbol 'function-documentation `(advice--make-docstring ',symbo= l)) > > 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. Indeed. =F0=9F=99=81 I guess this hasn't been noticed until now because `function-documentation` is not used very often. > How should I deal with that? Maybe essentially?: Well, we should fix it in `nadvice.el`, of course. But for compatibility with older Emacsen... > (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))) That sounds about right, tho you'd have to replace the `(documentation this-command)` with `(get this-command 'function-documentation)`. 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? Stefan From debbugs-submit-bounces@debbugs.gnu.org Wed Feb 26 11:12:35 2025 Received: (at 76528) by debbugs.gnu.org; 26 Feb 2025 16:12:35 +0000 Received: from localhost ([127.0.0.1]:54997 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tnK1T-0002dl-00 for submit@debbugs.gnu.org; Wed, 26 Feb 2025 11:12:35 -0500 Received: from mail.hostpark.net ([212.243.197.30]:39216) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tnK1O-0002dX-Oj for 76528@debbugs.gnu.org; Wed, 26 Feb 2025 11:12:32 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.hostpark.net (Postfix) with ESMTP id 56CB31657F; Wed, 26 Feb 2025 17:12:28 +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=1740586348; bh=lGBVRHJVckf2GEHdqgpB2zXJ61B64hisZTOY94rHR6M=; b= Hr4aNU5bb8quMAstj8Qu5pH+k7l8jQoKrP2xaKYFw4rxs7OCEZcOiA5t7V0TgBef lFrSYoxZvpn9dulOtsmfDSXV73bukDHNkDmh7tBFBd6/8sh4omYmNx77sDuH4pb8 fZnboX9VLrDhAhuMOJHhHKQdZ2vQ24b7cEStdK2rQ6U= X-Virus-Scanned: by Hostpark/NetZone Mailprotection at hostpark.net Received: from mail.hostpark.net ([127.0.0.1]) by localhost (mail1.hostpark.net [127.0.0.1]) (amavisd-new, port 10224) with ESMTP id v_5DB4TqnT5C; Wed, 26 Feb 2025 17:12:28 +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 79E22161D9; Wed, 26 Feb 2025 17:12:27 +0100 (CET) From: Jonas Bernoulli To: Stefan Monnier Subject: Re: bug#76528: 30; Advising functions can cause docstring to be lost In-Reply-To: References: <874j0jjj33.fsf@bernoul.li> <86r03nxi8l.fsf@gnu.org> <87cyf76pn7.fsf@bernoul.li> Date: Wed, 26 Feb 2025 17:12:25 +0100 Message-ID: <87seo08z2u.fsf@bernoul.li> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 76528 Cc: Eli Zaretskii , 76528@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) > 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