From unknown Sat Jun 14 05:07:44 2025 X-Loop: help-debbugs@gnu.org Subject: bug#50834: Feature request: cl-remove-method (prototyped) and buttons for it Resent-From: akater Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 27 Sep 2021 01:21:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 50834 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 50834@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.16327056333336 (code B ref -1); Mon, 27 Sep 2021 01:21:01 +0000 Received: (at submit) by debbugs.gnu.org; 27 Sep 2021 01:20:33 +0000 Received: from localhost ([127.0.0.1]:39154 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mUfJo-0000rj-Lb for submit@debbugs.gnu.org; Sun, 26 Sep 2021 21:20:32 -0400 Received: from lists.gnu.org ([209.51.188.17]:57336) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mUfJn-0000rc-F6 for submit@debbugs.gnu.org; Sun, 26 Sep 2021 21:20:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59714) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mUfJj-0003fq-9A for bug-gnu-emacs@gnu.org; Sun, 26 Sep 2021 21:20:29 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]:45877) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mUfJg-0000V3-IJ for bug-gnu-emacs@gnu.org; Sun, 26 Sep 2021 21:20:25 -0400 Received: by mail-wr1-x42d.google.com with SMTP id d21so47270240wra.12 for ; Sun, 26 Sep 2021 18:20:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:mime-version; bh=Ufy6oQF/1jBTXePBeWp31gAJTo378Xw81T4SGlq09PI=; b=k0UOp3iIyttVuqxz3lZIz8XihUzq1xBG0zOSr+4Y9MAHYmRLub9NkVXBQ+/X0/k5vy aN3w2zUMeK6g3Iwmth0akbJjv5NQQO+xRTtz23zEm6FrXQ5v4D0hVleZrvyXF4n7NWpT A5IylR+aNaqF0ilNJvporKKkuFKp/V2OGNNDTZ8mPRktndjEU8f4ZvCmI/jcmJTz/yIR +wPbGOhsup8jfPsDOVm2RSpluanR7rkCBGlV6+49fSoi/DXL3gzQLQ2x4XUazpa71wfY mOkaQmqCFbVsMgsu1j0f6RLDoTjCSzJAo78QAw4d5ig75TtzTSnfZL6nvnrhuszKoTDS aDrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version; bh=Ufy6oQF/1jBTXePBeWp31gAJTo378Xw81T4SGlq09PI=; b=Lr4VTyj/LVq1yo5anF38TYv1qSydbFR1GXSyoHTqObcyXPebRPpqO7t+oosSYR1p/G 8y1mUlwrRgwqCMyVbyXpzPF4jNv8MLn1+Whkvx20jtFlbXVLlkqopnpFiJOVFBmRXB0m qm1p+ASRpS13ocjctYURtR5W6AItdsIBZF5x6no6/BDPFP4YFeJujc0VyqrjAKS34SUk ybQ/6XstXmuLpzbLKrU32YMQ/l7Nzlm/kM+X/b9jH/Swi9zmcYXjDWlgow3e4yM31Sf5 CVZBFO5UXtPZBlffeiI5VywqnVN2tmxkEO4a7+bolkCmBEPtSxb5PuTiCP1Ksi38e340 xcqw== X-Gm-Message-State: AOAM533kJSvX9MNUSakNaa4xeNiLrup/7pGgZu5DetrP67ayDmM+JbBU Yd70mZcFGDkUug1YCV4Ud5UpiQR0zXY+5Osh X-Google-Smtp-Source: ABdhPJx6lmMKIwXmLN4NR85iOWK382A0cQCnr6vP2TcubZMOFlmvJ8S2pjWAE2YOGncAoD1jGwHmdA== X-Received: by 2002:a5d:6343:: with SMTP id b3mr23660187wrw.124.1632705622276; Sun, 26 Sep 2021 18:20:22 -0700 (PDT) Received: from localhost (tor-exit-15.zbau.f3netze.de. [185.220.100.242]) by smtp.googlemail.com with ESMTPSA id d129sm20218234wmd.23.2021.09.26.18.20.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Sep 2021 18:20:21 -0700 (PDT) From: akater Date: Mon, 27 Sep 2021 01:09:00 +0000 Message-ID: <8735pqq0yb.fsf@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=nuclearspace@gmail.com; helo=mail-wr1-x42d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) 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: -2.3 (--) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable I don't use CLOS or EIEIO very often but when I do, I remove methods all the time. I thus think it's a very important part of CLOS worflow. SLIME inspector (for Common Lisp) offers buttons that remove methods on the gf's page, e.g.: Name: PRINT-OBJECT Arguments: (SB-PCL::OBJECT STREAM) Method class: # Method combination: # Methods:=20 (TRACE-ENTRY T) [remove method] (UNREADABLE-RESULT T) [remove method] (CHANNEL T) [remove method] (CONNECTION T) [remove method] ... [remove method] are buttons. Sadly, Elisp doesn't have an inspector but I've heard of one effort github.com/mmontone/emacs-inspector and anyway, these buttons would be appropriate in any displayed list of methods, including the list currently shown in *Help* buffer for the gf. Example: Implementations: [remove] :around (object stream) in =E2=80=98cl-print.el=E2=80=99. Undocumented [remove] ((object string) stream) in =E2=80=98cl-print.el=E2=80=99. ... Recently it became necessary to use cl-remove-method in a library code so I tried to write it. The following seems to work but I'm very far from being confident about it. Also, methods are cached in lambdas returned by lambdas returned by cl--generic-get-dispatcher, and I haven't yet figured out a way to get them out of there; I'm also not sure if they should be removed manually, or the tables will just get GC'ed given the proposed implementation of cl-remove-method as is. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Add-cl-remove-method.patch Content-Description: Add cl-remove-method >From 50dc42ce1ea504657ccdcf85e9c71a2f27109610 Mon Sep 17 00:00:00 2001 From: akater Date: Sun, 26 Sep 2021 21:33:46 +0000 Subject: [PATCH] Add cl-remove-method --- lisp/emacs-lisp/cl-generic.el | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/lisp/emacs-lisp/cl-generic.el b/lisp/emacs-lisp/cl-generic.el index 1640975b84..7d5c8ddc0d 100644 --- a/lisp/emacs-lisp/cl-generic.el +++ b/lisp/emacs-lisp/cl-generic.el @@ -98,7 +98,7 @@ ;; usually be simplified, or even completely skipped. (eval-when-compile (require 'cl-lib)) -(eval-when-compile (require 'cl-macs)) ;For cl--find-class. +(eval-when-compile (require 'cl-macs)) ;For cl--find-class, cl-loop (eval-when-compile (require 'pcase)) (cl-defstruct (cl--generic-generalizer @@ -1255,6 +1255,35 @@ defun cl--generic-struct-specializers (tag &rest _) (cl--generic-prefill-dispatchers 0 integer) (cl--generic-prefill-dispatchers 0 cl--generic-generalizer integer) +(cl-defmethod cl-remove-method ((generic-function cl--generic) method) + "An equivalent of Common Lisp's method for remove-method +specialized on +(COMMON-LISP:STANDARD-GENERIC-FUNCTION COMMON-LISP:METHOD)." + (setf (cl--generic-method-table generic-function) + ;; delq could cause bugs, let's see if it does + (delq method (cl--generic-method-table generic-function))) + + (cl-loop for k being hash-key in cl--generic-combined-method-memoization + when (and (eq generic-function (car k)) + (memq method (cdr k))) + do (remhash k cl--generic-combined-method-memoization)) + + ;; It might make sense to move this + (defalias (cl--generic-name generic-function) + (cl--generic-make-function generic-function)) + ;; to an :after method + ;; but it's not even clear to me whether + ;; having such :after method would be compatible with Common Lisp standard. + generic-function) + +(cl-defmethod cl-remove-method ((generic-function symbol) method) + "For Common Lisp compatibility in Elisp. + +Namely, (cl-remove-method #'f ..) should work correctly but #'f returns symbol in Elisp." + (if-let ((gf (cl--generic generic-function))) + (cl-remove-method gf method) + (error "No generic function named %s" generic-function))) + ;;; Dispatch on major mode. ;; Two parts: -- 2.32.0 --=-=-=-- From unknown Sat Jun 14 05:07:44 2025 X-Loop: help-debbugs@gnu.org Subject: bug#50834: Feature request: cl-remove-method (prototyped) and buttons for it Resent-From: akater Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 27 Sep 2021 14:56:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50834 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 50834@debbugs.gnu.org Received: via spool by 50834-submit@debbugs.gnu.org id=B50834.1632754552775 (code B ref 50834); Mon, 27 Sep 2021 14:56:02 +0000 Received: (at 50834) by debbugs.gnu.org; 27 Sep 2021 14:55:52 +0000 Received: from localhost ([127.0.0.1]:42363 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mUs2p-0000CP-TV for submit@debbugs.gnu.org; Mon, 27 Sep 2021 10:55:52 -0400 Received: from mail-pl1-f175.google.com ([209.85.214.175]:47078) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mUs2o-0000CA-KM for 50834@debbugs.gnu.org; Mon, 27 Sep 2021 10:55:51 -0400 Received: by mail-pl1-f175.google.com with SMTP id w11so11925748plz.13 for <50834@debbugs.gnu.org>; Mon, 27 Sep 2021 07:55:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:in-reply-to:references:date:message-id:mime-version; bh=d27cYCU2aykiAgNPQbC8nLDDjYLLH9OMNE+N0F5LQ3w=; b=a8XDzWK5fq7djnJmN26uIprf1Ov1wC+S6MrjhU/RbCLY5HoiotIoYVDkarNiPqtlK6 wgzcZULmESZp2vGJ68MYpeSk1+8as5pLd6/9UMiA9RGiATBLOblalWqF93BN8UiMIZD+ 1kzz0hp5tGRkS/8VrmwSia/lps0gsDWxAdg+Ahieb0WPkoFLRq66ZT6rUO5tS5OOajKi ekdX3S7YoWMoC2r0YuKlDvzrqUU0dkkOc8AHt3/+KFpG0bL7L/MSuYBFWWAmITexN9Y+ cTXFaPV7xw3uoMDf2I96sGQb886Dw0octk7TTKt/1sWatsy7993r5YDVMBEcb+Fstmad Samg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:in-reply-to:references:date :message-id:mime-version; bh=d27cYCU2aykiAgNPQbC8nLDDjYLLH9OMNE+N0F5LQ3w=; b=u1TZ7/pylavXKAyr9SXmvzFfJkwm0KfXFeZPyRApwHfAUdA1nTBuW2T+HBkRrDe83n hnFmNqJCIJmCudGEUcb1nkoKZrhSjP80+SuDNV6yKR6z3vZHrjR59xXS/I3P2k7PZCCd AM+lVBQ2G3auaytKKSIjgEy/tSr28AESG3XP4uZWUxuRHn3o1/RTR7kuCWbWKhUwDJ0K H8V3bvvwfJMBxTVMF1C0C66C7O9APZDKy60+tWcqMeJWA4VUzYLYVZFVUuzKnbgLBRab sYQGXt2lgbRnpgrYFw66PRN0aQakOfdCnBYYDeuTc34HyEqJVYViqS89OMjp3jtWLMtt LW2w== X-Gm-Message-State: AOAM531wZ10HmNiqg1mKROXTmXsQzxs1lAccUVQWfxBWV/taxS4MmESb G9fpKzIJ7aNmftqE6bxkVMpzWJM5MCClxky1 X-Google-Smtp-Source: ABdhPJyyzGLJNdYS5YrXb0D6G8GwMFSwaqCfRX9JxXpmP/5opxFuGqnqp6Ttdq4j2e1bL5/2rzStIA== X-Received: by 2002:a17:902:b410:b0:13a:3f4a:db58 with SMTP id x16-20020a170902b41000b0013a3f4adb58mr265597plr.12.1632754544737; Mon, 27 Sep 2021 07:55:44 -0700 (PDT) Received: from localhost ([23.129.64.130]) by smtp.googlemail.com with ESMTPSA id e24sm17218714pfn.8.2021.09.27.07.55.43 for <50834@debbugs.gnu.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Sep 2021 07:55:44 -0700 (PDT) From: akater In-Reply-To: <8735pqq0yb.fsf@gmail.com> References: <8735pqq0yb.fsf@gmail.com> Date: Mon, 27 Sep 2021 14:44:13 +0000 Message-ID: <87wnn2nkn6.fsf@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 4.8 (++++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Various fixes to the prototype patch: - require subr-x - more specific default signature - more extensive documentation From decd4e0ed24553981f9b87f59308a10ccdd1c5b6 Mon Sep 17 00:00:00 2001 From: akater Date: Sun, 26 Sep 2021 21:33:46 +0000 Subject: [PATCH] Add cl-remove-method Content analysis details: (4.8 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 3.6 RCVD_IN_SBL_CSS RBL: Received via a relay in Spamhaus SBL-CSS [23.129.64.130 listed in zen.spamhaus.org] 1.2 RCVD_IN_BL_SPAMCOP_NET RBL: Received via a relay in bl.spamcop.net [Blocked - see ] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (nuclearspace[at]gmail.com) 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.214.175 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.214.175 listed in wl.mailspike.net] 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.8 (+++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Various fixes to the prototype patch: - require subr-x - more specific default signature - more extensive documentation From decd4e0ed24553981f9b87f59308a10ccdd1c5b6 Mon Sep 17 00:00:00 2001 From: akater Date: Sun, 26 Sep 2021 21:33:46 +0000 Subject: [PATCH] Add cl-remove-method Content analysis details: (3.8 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.214.175 listed in wl.mailspike.net] 3.6 RCVD_IN_SBL_CSS RBL: Received via a relay in Spamhaus SBL-CSS [23.129.64.130 listed in zen.spamhaus.org] 1.2 RCVD_IN_BL_SPAMCOP_NET RBL: Received via a relay in bl.spamcop.net [Blocked - see ] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.214.175 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (nuclearspace[at]gmail.com) 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -1.0 MAILING_LIST_MULTI Multiple indicators imply a widely-seen list manager --=-=-= Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" --==-=-= Content-Type: text/plain Various fixes to the prototype patch: - require subr-x - more specific default signature - more extensive documentation --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQJLBAEBCgA1FiEEgu5SJRdnQOF34djNsr6xYbHsf0QFAmFR2L0XHG51Y2xlYXJz cGFjZUBnbWFpbC5jb20ACgkQsr6xYbHsf0TcXhAAorEQxZdKc/aY/6EZz5dm1gR9 t07Pn/hsVLZL1ahBmPRph0SoMk8OdmhsuhPXxyh4oxiK3Cobuu7EZFbh/OxeIS3u x/6BY5o+uU9OUbrOM+ObdPP7j0vD2pPSVse6yC78Ag6RPLLlS4aASulTJ+uAaaPA uDCtCdh5KigKXJKc8xz9HwiZ0/8m+EKW0xuxk1EQAJysLn7+zy+OK9Q1PeeiiqMv UcAnhZyGlFb98H/NizWSj00qvqVcECwK89+m7Y1KacRMwHHxtPZOQOOHhOckbh66 9yjsVFaOQ/VudqgAE0+2uKRaIVKy2ue6yRwG3S2vXCnxf5Etz9KyrZ44q9p9dzwm vhu5DtGIo8w1gCioqJNruULm/WSzd7l6qeYwcdS1MNEZyoqCaIkjnXZlXNHWV+Jl Y83YIxuGW1esovmzFfBskHznedHq1HrYViRzGJD0oisDro5BDG/EgFN9W/CR97ZR ToKrPw5t4wt1OlUTnwKTYsK0NAciM08k7NKl3IB3bpOlCpQc5YvkMjtyo5r/9pyZ BP9dh+fKLHiyMXdJ4hEIrs9raXMhf7ATu/AiFJbQDvAqSD+6kYdoY2xmGmitdpjp FoZsIlcUP8b3aEkJ7IrPf0pUcl7HLRZApBDUrn9xFw15lSZOiCfwEkFfuyFp7tox 12v2wwTaRN5PWZJJGME= =pore -----END PGP SIGNATURE----- --==-=-=-- --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Add-cl-remove-method.patch Content-Description: Add cl-remove-method >From decd4e0ed24553981f9b87f59308a10ccdd1c5b6 Mon Sep 17 00:00:00 2001 From: akater Date: Sun, 26 Sep 2021 21:33:46 +0000 Subject: [PATCH] Add cl-remove-method --- lisp/emacs-lisp/cl-generic.el | 56 ++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/lisp/emacs-lisp/cl-generic.el b/lisp/emacs-lisp/cl-generic.el index 1640975b84..c1ef3af3c7 100644 --- a/lisp/emacs-lisp/cl-generic.el +++ b/lisp/emacs-lisp/cl-generic.el @@ -98,8 +98,9 @@ ;; usually be simplified, or even completely skipped. (eval-when-compile (require 'cl-lib)) -(eval-when-compile (require 'cl-macs)) ;For cl--find-class. +(eval-when-compile (require 'cl-macs)) ;For cl--find-class, cl-loop (eval-when-compile (require 'pcase)) +(eval-when-compile (require 'subr-x)) ;if-let (cl-defstruct (cl--generic-generalizer (:constructor nil) @@ -1255,6 +1256,59 @@ defun cl--generic-struct-specializers (tag &rest _) (cl--generic-prefill-dispatchers 0 integer) (cl--generic-prefill-dispatchers 0 cl--generic-generalizer integer) +(cl-defgeneric cl-remove-method (generic-function method) + "Remove METHOD from GENERIC-FUNCTION by modifying the +GENERIC-FUNCTION (if necessary). + +`cl-remove-method' does not signal an error if METHOD is not one +of the methods on the GENERIC-FUNCTION.") + +(cl-defmethod cl-remove-method ((generic-function cl--generic) + (method cl--generic-method)) + "An equivalent of Common Lisp's default method for remove-method. + +Compatibility note: +The Common Lisp HyperSpec page on remove-method says +in Arguments and Values: + > method---a method +and Exceptional Situations: none. +So then, according to +1.4.4.3 The ``Arguments and Values'' Section of a Dictionary Entry +http://www.lispworks.com/reference/HyperSpec/Body/01_ddc.htm + +the consequences are undefined if the second value is not a method. + +In cl-generic, `cl-remove-method' is not applicable to +non-methods by default." + ;; Credit for compatibility note goes to + ;; beach from #commonlisp at libera.chat + (setf (cl--generic-method-table generic-function) + ;; delq could cause bugs, let's see if it does + (delq method (cl--generic-method-table generic-function))) + + (cl-loop for k being hash-key in cl--generic-combined-method-memoization + when (and (eq generic-function (car k)) + (memq method (cdr k))) + do (remhash k cl--generic-combined-method-memoization)) + + ;; It might make sense to move this + (defalias (cl--generic-name generic-function) + (cl--generic-make-function generic-function)) + ;; to an :after method + ;; but it's not even clear to me whether + ;; having such :after method would be compatible with Common Lisp standard. + generic-function) + +(cl-defmethod cl-remove-method ((generic-function symbol) + (method cl--generic-method)) + "For Common Lisp compatibility in Elisp. + +Namely, (cl-remove-method #'f ..) should work correctly but #'f +returns symbol in Elisp, hence this method." + (if-let ((gf (cl--generic generic-function))) + (cl-remove-method gf method) + (error "No generic function named %s" generic-function))) + ;;; Dispatch on major mode. ;; Two parts: -- 2.32.0 --=-=-=-- From unknown Sat Jun 14 05:07:44 2025 X-Loop: help-debbugs@gnu.org Subject: bug#50834: Feature request: cl-remove-method (prototyped) and buttons for it Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 02 Sep 2022 10:57:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50834 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: akater Cc: Stefan Monnier , 50834@debbugs.gnu.org Received: via spool by 50834-submit@debbugs.gnu.org id=B50834.16621161788267 (code B ref 50834); Fri, 02 Sep 2022 10:57:01 +0000 Received: (at 50834) by debbugs.gnu.org; 2 Sep 2022 10:56:18 +0000 Received: from localhost ([127.0.0.1]:45010 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oU4LS-00029F-GF for submit@debbugs.gnu.org; Fri, 02 Sep 2022 06:56:18 -0400 Received: from quimby.gnus.org ([95.216.78.240]:34172) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oU4LP-00028t-JI for 50834@debbugs.gnu.org; Fri, 02 Sep 2022 06:56:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:Date:References: In-Reply-To:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=nBXuUKp0BgauCaWknLyIMLboPafZR1biZ/1qhPlEo5A=; b=RaPU3TootmTv9Trua5sKxtpcLp V7SELWfJZ7xus7t7y2YMbbQN9CUh5RpcWVOnBiE9UN9eFNRyPWPxLsQ7wdCijoqypbGlHUQsrWlD3 skf4gxUGmFgbKpzjOiGxpPma4PNo8ApRpb2+cHMKl930BZNirIt9cvaWbgieBr1eCk1s=; Received: from [84.212.220.105] (helo=joga) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oU4LF-0004l4-Vc; Fri, 02 Sep 2022 12:56:08 +0200 From: Lars Ingebrigtsen In-Reply-To: <87wnn2nkn6.fsf@gmail.com> (akater's message of "Mon, 27 Sep 2021 14:44:13 +0000") References: <8735pqq0yb.fsf@gmail.com> <87wnn2nkn6.fsf@gmail.com> X-Now-Playing: The Cure's _Bloodflowers_: "Out of This World" Date: Fri, 02 Sep 2022 12:56:05 +0200 Message-ID: <8735daxcxm.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: akater writes: > +(cl-defgeneric cl-remove-method (generic-function method) > + "Remove METHOD from GENERIC-FUNCTION by modifying the > +GENERIC-FUNCTION (if necessary). I think this sounds very useful -- I don't think we have any other ways to remove a method, and that's something that I've been missing sometimes when implementing stuff. Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: -2.3 (--) 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 (---) akater writes: > +(cl-defgeneric cl-remove-method (generic-function method) > + "Remove METHOD from GENERIC-FUNCTION by modifying the > +GENERIC-FUNCTION (if necessary). I think this sounds very useful -- I don't think we have any other ways to remove a method, and that's something that I've been missing sometimes when implementing stuff. Perhaps Stefan has some comments here; added to the CCs. From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 02 06:56:18 2022 Received: (at control) by debbugs.gnu.org; 2 Sep 2022 10:56:19 +0000 Received: from localhost ([127.0.0.1]:45012 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oU4LS-00029I-PH for submit@debbugs.gnu.org; Fri, 02 Sep 2022 06:56:18 -0400 Received: from quimby.gnus.org ([95.216.78.240]:34188) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oU4LR-00028w-SX for control@debbugs.gnu.org; Fri, 02 Sep 2022 06:56:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Subject:From:To:Message-Id:Date:Sender:Reply-To:Cc: MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=l3eCoJDatDbSRx+BsJJn+JA3LehQmdLlLiHARoIwgfI=; b=ikaMwM/oultEB7YsvXk0dZQ0KH 2Me9Zv4qcXZfAFNOcOkp6Z3hwbFR1pKak0szidk68NSzHW7+ccav30dB1vd1Gt3TwY32suF32MfAY hIIKVxnu0wFlSxZNmOY5f+YcZYXCdA7f/3YJxud1ZkTGwfz1axCn4CBD1wNIYXjHaD4Y=; Received: from [84.212.220.105] (helo=joga) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oU4LK-0004l9-0U for control@debbugs.gnu.org; Fri, 02 Sep 2022 12:56:12 +0200 Date: Fri, 02 Sep 2022 12:56:09 +0200 Message-Id: <871qsuxcxi.fsf@gnus.org> To: control@debbugs.gnu.org From: Lars Ingebrigtsen Subject: control message for bug #50834 X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: tags 50834 + moreinfo quit Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: -2.3 (--) 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: -3.3 (---) tags 50834 + moreinfo quit From unknown Sat Jun 14 05:07:44 2025 X-Loop: help-debbugs@gnu.org Subject: bug#50834: Feature request: cl-remove-method (prototyped) and buttons for it Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 02 Sep 2022 13:30:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50834 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: moreinfo To: Lars Ingebrigtsen Cc: akater , 50834@debbugs.gnu.org Received: via spool by 50834-submit@debbugs.gnu.org id=B50834.166212536817150 (code B ref 50834); Fri, 02 Sep 2022 13:30:02 +0000 Received: (at 50834) by debbugs.gnu.org; 2 Sep 2022 13:29:28 +0000 Received: from localhost ([127.0.0.1]:45348 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oU6jg-0004SY-BB for submit@debbugs.gnu.org; Fri, 02 Sep 2022 09:29:28 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:34313) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oU6je-0004SL-2P for 50834@debbugs.gnu.org; Fri, 02 Sep 2022 09:29:26 -0400 Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 2D399440FD8; Fri, 2 Sep 2022 09:29:20 -0400 (EDT) Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id C649D440613; Fri, 2 Sep 2022 09:29:18 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1662125358; bh=1hPJIbrTi55niLRk407C5IL9tyMQAD3IwwqisZUgTUo=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=GZ0jdqsUJsQC/bJoe02CT06HXzenYGHZkuaD1k2Rwq7ht+cBb4yQFMHbcjkRPMrvn bgk5xT89gTipDPJU9pnoqRHaDnBg7eBTxiZk4RA3PW8RgVkHb0+y/rbqLqyKtZYCsx aRF176ZaTUq4LunA34aBs+eTNTT5ubVv5bV9eh4Ij3/VBNrFqcH0wrOTXUaVfIh/3K iBFpadrZ/6moHvfvjHvpFIhUQ9qbciU4ApQ/k5/su26II9aMZsPs03NYucGpckzbJK lwPxtf5f5sX/yUqd78eJ82iHJZexpmRWS7lxdYCK1j7Qy97nINItmpkq+Rv7UEfGNy CTAiVmptF9Fhw== Received: from pastel (unknown [157.52.9.190]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 9DFF51200A5; Fri, 2 Sep 2022 09:29:18 -0400 (EDT) From: Stefan Monnier In-Reply-To: <8735daxcxm.fsf@gnus.org> (Lars Ingebrigtsen's message of "Fri, 02 Sep 2022 12:56:05 +0200") Message-ID: References: <8735pqq0yb.fsf@gmail.com> <87wnn2nkn6.fsf@gmail.com> <8735daxcxm.fsf@gnus.org> Date: Fri, 02 Sep 2022 09:29:16 -0400 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) 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 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 T_SCC_BODY_TEXT_LINE -0.01 - X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) 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 (---) Lars Ingebrigtsen [2022-09-02 12:56:05] wrote: > akater writes: >> +(cl-defgeneric cl-remove-method (generic-function method) >> + "Remove METHOD from GENERIC-FUNCTION by modifying the >> +GENERIC-FUNCTION (if necessary). > I think this sounds very useful -- I don't think we have any other ways > to remove a method, and that's something that I've been missing > sometimes when implementing stuff. I'd challenge your use of "very", but I agree it's missing. > Perhaps Stefan has some comments here; added to the CCs. Not much to say, except: > + (cl-loop for k being hash-key in cl--generic-combined-method-memoization > + when (and (eq generic-function (car k)) > + (memq method (cdr k))) > + do (remhash k cl--generic-combined-method-memoization)) I don't see why we'd need this. This is a cache that tries to speed up the construction of combined methods, whereas in `cl-remove-method` we should only need to flush the cache that maps tags to their corresponding combined methods and this is done implicitly by `cl--generic-make-function` (which returns a new function with a branch new fresh cache). Stefan From unknown Sat Jun 14 05:07:44 2025 X-Loop: help-debbugs@gnu.org Subject: bug#50834: Feature request: cl-remove-method (prototyped) and buttons for it Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 04 Oct 2022 12:20:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50834 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: moreinfo To: Stefan Monnier Cc: akater , 50834@debbugs.gnu.org Received: via spool by 50834-submit@debbugs.gnu.org id=B50834.166488599525524 (code B ref 50834); Tue, 04 Oct 2022 12:20:02 +0000 Received: (at 50834) by debbugs.gnu.org; 4 Oct 2022 12:19:55 +0000 Received: from localhost ([127.0.0.1]:52808 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ofgtv-0006db-1d for submit@debbugs.gnu.org; Tue, 04 Oct 2022 08:19:55 -0400 Received: from quimby.gnus.org ([95.216.78.240]:45574) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ofgtt-0006dM-Vk for 50834@debbugs.gnu.org; Tue, 04 Oct 2022 08:19:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:Date:References: In-Reply-To:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=Xo+wAPcoIxKL6HYoMkRwhz5FoiBINK2feufQ2B2xLKw=; b=JwwnWhBUTGRBgV9Ag/7SenMPz/ FMESGzkbCnl+Yn6NB/m91NgUKVorkR3ElLr0QUASo+RpBnULWSmrMQTPV5RAiv8EXE28WcLGQTqOV kDgCwHWCmUynStOM3rniTAHfVj1QVSQCGBqRZ2vyeHY3RI7yWY9lGi21uAd8iK4HzkyU=; Received: from [84.212.220.105] (helo=downe) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ofgtk-0003gQ-TY; Tue, 04 Oct 2022 14:19:47 +0200 From: Lars Ingebrigtsen In-Reply-To: (Stefan Monnier's message of "Fri, 02 Sep 2022 09:29:16 -0400") References: <8735pqq0yb.fsf@gmail.com> <87wnn2nkn6.fsf@gmail.com> <8735daxcxm.fsf@gnus.org> X-Now-Playing: Peter Principle's _Sedimental Journey_: "The Anvil Chorus" Date: Tue, 04 Oct 2022 14:19:44 +0200 Message-ID: <87a66b93xb.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Stefan Monnier writes: > Not much to say, except: > >> + (cl-loop for k being hash-key in cl--generic-combined-method-memoization >> + when (and (eq generic-function (car k)) >> + (memq method (cdr k))) >> + do (remhash k c [...] Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: -2.3 (--) 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 Monnier writes: > Not much to say, except: > >> + (cl-loop for k being hash-key in cl--generic-combined-method-memoization >> + when (and (eq generic-function (car k)) >> + (memq method (cdr k))) >> + do (remhash k cl--generic-combined-method-memoization)) > > I don't see why we'd need this. > > This is a cache that tries to speed up the construction of combined > methods, whereas in `cl-remove-method` we should only need to flush the > cache that maps tags to their corresponding combined methods and this is > done implicitly by `cl--generic-make-function` (which returns a new > function with a branch new fresh cache). Akater, do you have any comments (or an amended patch)? From unknown Sat Jun 14 05:07:44 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: akater Subject: bug#50834: closed (Re: bug#50834: Feature request: cl-remove-method (prototyped) and buttons for it) Message-ID: References: <8735pqq0yb.fsf@gmail.com> X-Gnu-PR-Message: they-closed 50834 X-Gnu-PR-Package: emacs X-Gnu-PR-Keywords: moreinfo Reply-To: 50834@debbugs.gnu.org Date: Sun, 03 Sep 2023 08:39:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1693730342-22529-1" This is a multi-part message in MIME format... ------------=_1693730342-22529-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #50834: Feature request: cl-remove-method (prototyped) and buttons for it which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 50834@debbugs.gnu.org. --=20 50834: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D50834 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1693730342-22529-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 50834-done) by debbugs.gnu.org; 3 Sep 2023 08:39:01 +0000 Received: from localhost ([127.0.0.1]:39256 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qcidI-0005r2-Sp for submit@debbugs.gnu.org; Sun, 03 Sep 2023 04:39:01 -0400 Received: from mail-lf1-x12a.google.com ([2a00:1450:4864:20::12a]:42394) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qcidG-0005qm-NS for 50834-done@debbugs.gnu.org; Sun, 03 Sep 2023 04:38:59 -0400 Received: by mail-lf1-x12a.google.com with SMTP id 2adb3069b0e04-500bbe3ef0eso550364e87.1 for <50834-done@debbugs.gnu.org>; Sun, 03 Sep 2023 01:38:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693730322; x=1694335122; darn=debbugs.gnu.org; h=cc:to:subject:message-id:date:mime-version:references:in-reply-to :from:from:to:cc:subject:date:message-id:reply-to; bh=Ny7R6/lz9+7xOk1X6Wx4YrMDxyMBMFB+ZqHIvvBMxKE=; b=N+8y3P6wuq/BZb/2kBaiEHHjBi9UfHaJtu6D+5I5r2RI/Hlv4tSBs9bfNSyzzjc4ZH NqZxoOLrHrzA+DSIyCruSZkQnv56hS/gLkiM2CU46vrLphh6azpQI65GY67HnL1gwFXM cVpzqmdtW7gVeL/n6duKy6EiiTtuR/V4FTcSqgr0E+Borfu+PIm+2dbi3Q9aKs2GkzGP eziixqp+7zdWr/CY3fVk4sS7NhX//4pNI9BLcT0dQEZj/x39eNbqqLjGU1DyK2B9gXxV 8SWHnw8zlmh5Yf19XC5/+Bmbxae68uEvDcq/4q/QdIjtP1zxHwYZeP9prkbPGscfuyey 03Gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693730322; x=1694335122; h=cc:to:subject:message-id:date:mime-version:references:in-reply-to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Ny7R6/lz9+7xOk1X6Wx4YrMDxyMBMFB+ZqHIvvBMxKE=; b=U9MxE92yslig9D92AzIyILODpvKv7anEKYHVgj72MrlhL8E5zx0Qtb1xp32stouOXv 3T1tlJO+qoJ0CpeEX6ZLsLYOhYYdnsgGuuj74VyJzeqVPUFWh0s74u0PY2ur9cF9tV/i rlN4gNJvSDQabEZNQly/W88z5VIvOovXEXgU+moxEPvEOJcr8DrEQbe2NbyeV2hMfUig Vtf5EXcvScl1k9rNtz694M4+aGp3dAHbQzWfx/gCPxrIzsgFKdAnRuHfGb2hyzM6gWeY us6NnjkJAuqyadbxbEILAfMs+vXI6G+hUKVvzmTjbcdI29hnrjJrm6qdtJ7RkVuMP2kZ JUNw== X-Gm-Message-State: AOJu0YwHWNGaDDjcmNRLWQE7K7gdi0X8Jnc02bqbP8nuBA5Sg3VEhZCt 159hicUUf5eP78dltdnvFy6XmnXUppT2OF0T0YGNR7y9CUg= X-Google-Smtp-Source: AGHT+IG1zETftT9Ea1AoAGYVCYPLoyADMJY/50yn7mncT+Qe+O3z1czCFj+SbIpkEuh3AP42n+p591aSb2mPOgqBdKM= X-Received: by 2002:a19:9103:0:b0:4fd:c8fb:eb71 with SMTP id t3-20020a199103000000b004fdc8fbeb71mr1863471lfd.11.1693730322342; Sun, 03 Sep 2023 01:38:42 -0700 (PDT) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Sun, 3 Sep 2023 01:38:41 -0700 From: Stefan Kangas In-Reply-To: <87a66b93xb.fsf@gnus.org> (Lars Ingebrigtsen's message of "Tue, 04 Oct 2022 14:19:44 +0200") References: <8735pqq0yb.fsf@gmail.com> <87wnn2nkn6.fsf@gmail.com> <8735daxcxm.fsf@gnus.org> <87a66b93xb.fsf@gnus.org> MIME-Version: 1.0 Date: Sun, 3 Sep 2023 01:38:41 -0700 Message-ID: Subject: Re: bug#50834: Feature request: cl-remove-method (prototyped) and buttons for it To: Lars Ingebrigtsen Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 50834-done Cc: 50834-done@debbugs.gnu.org, Stefan Monnier , akater 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 (-) Lars Ingebrigtsen writes: > Stefan Monnier writes: > >> Not much to say, except: >> >>> + (cl-loop for k being hash-key in cl--generic-combined-method-memoization >>> + when (and (eq generic-function (car k)) >>> + (memq method (cdr k))) >>> + do (remhash k cl--generic-combined-method-memoization)) >> >> I don't see why we'd need this. >> >> This is a cache that tries to speed up the construction of combined >> methods, whereas in `cl-remove-method` we should only need to flush the >> cache that maps tags to their corresponding combined methods and this is >> done implicitly by `cl--generic-make-function` (which returns a new >> function with a branch new fresh cache). > > Akater, do you have any comments (or an amended patch)? More information was requested, but none was given within 10 months, so I'm closing this bug. If this is still an issue, please reply to this email (use "Reply to all" in your email client) and we can reopen the bug report. ------------=_1693730342-22529-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 27 Sep 2021 01:20:33 +0000 Received: from localhost ([127.0.0.1]:39154 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mUfJo-0000rj-Lb for submit@debbugs.gnu.org; Sun, 26 Sep 2021 21:20:32 -0400 Received: from lists.gnu.org ([209.51.188.17]:57336) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mUfJn-0000rc-F6 for submit@debbugs.gnu.org; Sun, 26 Sep 2021 21:20:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59714) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mUfJj-0003fq-9A for bug-gnu-emacs@gnu.org; Sun, 26 Sep 2021 21:20:29 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]:45877) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mUfJg-0000V3-IJ for bug-gnu-emacs@gnu.org; Sun, 26 Sep 2021 21:20:25 -0400 Received: by mail-wr1-x42d.google.com with SMTP id d21so47270240wra.12 for ; Sun, 26 Sep 2021 18:20:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:mime-version; bh=Ufy6oQF/1jBTXePBeWp31gAJTo378Xw81T4SGlq09PI=; b=k0UOp3iIyttVuqxz3lZIz8XihUzq1xBG0zOSr+4Y9MAHYmRLub9NkVXBQ+/X0/k5vy aN3w2zUMeK6g3Iwmth0akbJjv5NQQO+xRTtz23zEm6FrXQ5v4D0hVleZrvyXF4n7NWpT A5IylR+aNaqF0ilNJvporKKkuFKp/V2OGNNDTZ8mPRktndjEU8f4ZvCmI/jcmJTz/yIR +wPbGOhsup8jfPsDOVm2RSpluanR7rkCBGlV6+49fSoi/DXL3gzQLQ2x4XUazpa71wfY mOkaQmqCFbVsMgsu1j0f6RLDoTjCSzJAo78QAw4d5ig75TtzTSnfZL6nvnrhuszKoTDS aDrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version; bh=Ufy6oQF/1jBTXePBeWp31gAJTo378Xw81T4SGlq09PI=; b=Lr4VTyj/LVq1yo5anF38TYv1qSydbFR1GXSyoHTqObcyXPebRPpqO7t+oosSYR1p/G 8y1mUlwrRgwqCMyVbyXpzPF4jNv8MLn1+Whkvx20jtFlbXVLlkqopnpFiJOVFBmRXB0m qm1p+ASRpS13ocjctYURtR5W6AItdsIBZF5x6no6/BDPFP4YFeJujc0VyqrjAKS34SUk ybQ/6XstXmuLpzbLKrU32YMQ/l7Nzlm/kM+X/b9jH/Swi9zmcYXjDWlgow3e4yM31Sf5 CVZBFO5UXtPZBlffeiI5VywqnVN2tmxkEO4a7+bolkCmBEPtSxb5PuTiCP1Ksi38e340 xcqw== X-Gm-Message-State: AOAM533kJSvX9MNUSakNaa4xeNiLrup/7pGgZu5DetrP67ayDmM+JbBU Yd70mZcFGDkUug1YCV4Ud5UpiQR0zXY+5Osh X-Google-Smtp-Source: ABdhPJx6lmMKIwXmLN4NR85iOWK382A0cQCnr6vP2TcubZMOFlmvJ8S2pjWAE2YOGncAoD1jGwHmdA== X-Received: by 2002:a5d:6343:: with SMTP id b3mr23660187wrw.124.1632705622276; Sun, 26 Sep 2021 18:20:22 -0700 (PDT) Received: from localhost (tor-exit-15.zbau.f3netze.de. [185.220.100.242]) by smtp.googlemail.com with ESMTPSA id d129sm20218234wmd.23.2021.09.26.18.20.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Sep 2021 18:20:21 -0700 (PDT) From: akater To: bug-gnu-emacs@gnu.org Subject: Feature request: cl-remove-method (prototyped) and buttons for it Date: Mon, 27 Sep 2021 01:09:00 +0000 Message-ID: <8735pqq0yb.fsf@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=nuclearspace@gmail.com; helo=mail-wr1-x42d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) 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: -2.3 (--) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable I don't use CLOS or EIEIO very often but when I do, I remove methods all the time. I thus think it's a very important part of CLOS worflow. SLIME inspector (for Common Lisp) offers buttons that remove methods on the gf's page, e.g.: Name: PRINT-OBJECT Arguments: (SB-PCL::OBJECT STREAM) Method class: # Method combination: # Methods:=20 (TRACE-ENTRY T) [remove method] (UNREADABLE-RESULT T) [remove method] (CHANNEL T) [remove method] (CONNECTION T) [remove method] ... [remove method] are buttons. Sadly, Elisp doesn't have an inspector but I've heard of one effort github.com/mmontone/emacs-inspector and anyway, these buttons would be appropriate in any displayed list of methods, including the list currently shown in *Help* buffer for the gf. Example: Implementations: [remove] :around (object stream) in =E2=80=98cl-print.el=E2=80=99. Undocumented [remove] ((object string) stream) in =E2=80=98cl-print.el=E2=80=99. ... Recently it became necessary to use cl-remove-method in a library code so I tried to write it. The following seems to work but I'm very far from being confident about it. Also, methods are cached in lambdas returned by lambdas returned by cl--generic-get-dispatcher, and I haven't yet figured out a way to get them out of there; I'm also not sure if they should be removed manually, or the tables will just get GC'ed given the proposed implementation of cl-remove-method as is. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Add-cl-remove-method.patch Content-Description: Add cl-remove-method >From 50dc42ce1ea504657ccdcf85e9c71a2f27109610 Mon Sep 17 00:00:00 2001 From: akater Date: Sun, 26 Sep 2021 21:33:46 +0000 Subject: [PATCH] Add cl-remove-method --- lisp/emacs-lisp/cl-generic.el | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/lisp/emacs-lisp/cl-generic.el b/lisp/emacs-lisp/cl-generic.el index 1640975b84..7d5c8ddc0d 100644 --- a/lisp/emacs-lisp/cl-generic.el +++ b/lisp/emacs-lisp/cl-generic.el @@ -98,7 +98,7 @@ ;; usually be simplified, or even completely skipped. (eval-when-compile (require 'cl-lib)) -(eval-when-compile (require 'cl-macs)) ;For cl--find-class. +(eval-when-compile (require 'cl-macs)) ;For cl--find-class, cl-loop (eval-when-compile (require 'pcase)) (cl-defstruct (cl--generic-generalizer @@ -1255,6 +1255,35 @@ defun cl--generic-struct-specializers (tag &rest _) (cl--generic-prefill-dispatchers 0 integer) (cl--generic-prefill-dispatchers 0 cl--generic-generalizer integer) +(cl-defmethod cl-remove-method ((generic-function cl--generic) method) + "An equivalent of Common Lisp's method for remove-method +specialized on +(COMMON-LISP:STANDARD-GENERIC-FUNCTION COMMON-LISP:METHOD)." + (setf (cl--generic-method-table generic-function) + ;; delq could cause bugs, let's see if it does + (delq method (cl--generic-method-table generic-function))) + + (cl-loop for k being hash-key in cl--generic-combined-method-memoization + when (and (eq generic-function (car k)) + (memq method (cdr k))) + do (remhash k cl--generic-combined-method-memoization)) + + ;; It might make sense to move this + (defalias (cl--generic-name generic-function) + (cl--generic-make-function generic-function)) + ;; to an :after method + ;; but it's not even clear to me whether + ;; having such :after method would be compatible with Common Lisp standard. + generic-function) + +(cl-defmethod cl-remove-method ((generic-function symbol) method) + "For Common Lisp compatibility in Elisp. + +Namely, (cl-remove-method #'f ..) should work correctly but #'f returns symbol in Elisp." + (if-let ((gf (cl--generic generic-function))) + (cl-remove-method gf method) + (error "No generic function named %s" generic-function))) + ;;; Dispatch on major mode. ;; Two parts: -- 2.32.0 --=-=-=-- ------------=_1693730342-22529-1--