From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Po Lu via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#54802: OClosure: Make `interactive-form` a generic function Date: Fri, 15 Apr 2022 08:46:55 +0800 Message-ID: <87v8vbrx4w.fsf@yahoo.com> References: <87r161to4p.fsf@yahoo.com> Reply-To: Po Lu Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="35780"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.91 (gnu/linux) Cc: 54802@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Apr 15 02:48:11 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nfA8A-00094b-E5 for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 15 Apr 2022 02:48:11 +0200 Original-Received: from localhost ([::1]:37320 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nfA89-0005L4-1d for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 14 Apr 2022 20:48:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56738) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nfA82-0005Kp-Ao for bug-gnu-emacs@gnu.org; Thu, 14 Apr 2022 20:48:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:35545) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nfA82-0007t0-2I for bug-gnu-emacs@gnu.org; Thu, 14 Apr 2022 20:48:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nfA82-0001Bh-0f for bug-gnu-emacs@gnu.org; Thu, 14 Apr 2022 20:48:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Po Lu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 15 Apr 2022 00:48:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 54802 X-GNU-PR-Package: emacs Original-Received: via spool by 54802-submit@debbugs.gnu.org id=B54802.16499836344353 (code B ref 54802); Fri, 15 Apr 2022 00:48:01 +0000 Original-Received: (at 54802) by debbugs.gnu.org; 15 Apr 2022 00:47:14 +0000 Original-Received: from localhost ([127.0.0.1]:57675 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nfA7F-000188-Jr for submit@debbugs.gnu.org; Thu, 14 Apr 2022 20:47:13 -0400 Original-Received: from sonic303-22.consmr.mail.ne1.yahoo.com ([66.163.188.148]:41924) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nfA7C-00017s-Oy for 54802@debbugs.gnu.org; Thu, 14 Apr 2022 20:47:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1649983625; bh=rLNvubOFWr4WYB1ct4C3bmOO6Jtl+jLaNob0BiIOEe0=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From:Subject:Reply-To; b=i1u4mgCuXdygnUBw8sffB5PIuiY3FRp18Hf0B8nf6tGbzMh21to35+T46rUzDsO6snCU/hJ+QE9ygC4q1xLVf85GmAjAyiVu7LLDY3M1Pl3SRD1vO1+XYFrezn4It01I2Hcq5ZvoHiWcPEQ8R8mGQ2ZHaDCexU7yFY0W0mUEzOcKnIQA4DT3ktmu72prGdazYP0z+CS+grheKO/A9OBIzG2Oghv3lg0JxzAVkD2D3/WNGMj639gCCo8+1x7GXqKNJq5lN3+JgnE8KYpEwZBIHBTKdLE9QO/yNv1WaKa7x93KATqbsLKeA+Ltb9DpZ2h09UtsLc+5ElhtQyizAFxZPA== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1649983625; bh=gUXaJbXUzWfibVgXUT5d7DeXc028rU/vYaGXBVT4Jo6=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=Q9a5Sq8WwJ5UjByPaDNwvNfs2o13dgOnprBuTPtH9OfdmszhMx0TUtlQm/MrNcuqI8EHdHTCfTXYW6wPiYBoKjJ0sZnmhLqPFPVVSoOegMQOzEyArRTnZkvtkw+/prycRhOFlmWMpRGmkrfzq8k+9o1vtxDjH0vO7L2VxkJVemYcWlJxT3RflLqiFpNCkmUdsQiiA1v/yNfUSLF8DjYVCLfiNM2QT1bZk0vhC5SkSpqFROD5P/CISY11dPN5lOJvmeNJUEhegw1y2FcfDqgpsb8jCvQvb3xIKws5s59X+j9Tai8M71uZoSmgHZc6ylNT/59wZGGH8DWSu4NSJ70RGA== X-YMail-OSG: tIRw9HMVM1lI6t20Wv56Tg.Wbc3qOsj19.KznXMWK7T1OvKT53CnoCQbE4VIuV8 5eYmF9ULWgv908lJZ2WLSJhX2uz3NpaFY0RfJME0XNHiKbKlckM_RQZL892sUuNzlpz26x5I0o6v JtiProqjenXIPxw9c2jODijUD0Uponi7vMkItUfJ7btdTTSrDpL.senjyFP841fhIEgFXe.lG00u vWwJwDKVicW7ioEiSGHBX_JqWyiTYVtSYiP1zXU1T9d0r5oGxfVCFyiefwY2Ezb2H46LY88dEQLa 7Th0OQ.7NjrQPaIxbPbnmubB6.Iynt7mvi_Q_wqOho9CQy0Vz8V76HZKBg7laJM73bKC1CCY43hV rYwn1Am9WIKWdcd0OvYhPAEtpDWAbWuIXMhu1oTYoV1ud0CqAVnoJ89v13rCVIPL0H.FzHueBsPc V1OTRXIUQg_fK_nwxynN5MslwYdzilUbZQc3TEcsqLer6jXXar1C_f7dR_ynpGx4ObuxBDWi7bMa G_LM89E3GY_J.l9YM2ZXc5EGuhaeBeawkiTf2gJWU2EAiMmc4uDPzsabS31kM6HU7QUmWSbEOlOy yJxggecxuxY98_SohEOhLzUnz77uTf.hLtAh.aKF5dfcx2et7HVps8sBZlAxmIQbDc_Tk7WaM4OL aR2T8GXDKCPbWnO_5dg7uNa_kTiBfGnLeTsF8TPwmtoaD70U4ZzNv6vgiTrPcPrJgJ75Wrm574v4 sVqEKSPKcm1vjeiC1mphvfr.oBF3GImgEhGZhOm3Zf9LSAeeGdX_FCsd_AI6U4QlPP8E9drR4Xuu oUOdm1rVY6CTEf_9ABPaQG6lN1z7K7Gn7uEIQex75u X-Sonic-MF: Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic303.consmr.mail.ne1.yahoo.com with HTTP; Fri, 15 Apr 2022 00:47:05 +0000 Original-Received: by hermes--canary-production-sg3-cfddc4f9d-6mzbv (VZM Hermes SMTP Server) with ESMTPA ID 3ca1f074b1fae4090cbc155af4f06b7e; Fri, 15 Apr 2022 00:47:00 +0000 (UTC) In-Reply-To: (Stefan Monnier's message of "Thu, 14 Apr 2022 14:34:24 -0400") X-Mailer: WebService/1.1.20048 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:229901 Archived-At: Stefan Monnier writes: > Do you have actual examples in some existing package? Just the one I wrote for myself. > Interesting. I just tested this in an `all-completions` loop and my > patch makes it run a factor of 2 slower (it went from ~30ms to ~60ms to > enumerate the 141 commands that matched). > > There are some mitigating circumstances, tho: > - The first call to this code takes a lot of time (~6s) because > it loads a crapload of packages (every package with a registered > autoloaded command). Indeed, that's a problem I know of, but it solves itself after the first call. > - It's very brittle since it won't find those commands that have > interactive specs like "r\np" or where it's not a string (like > `kill-region` and many others, actually there are regularly more, e.g. > to make them obey `use-region-p`). Hmm, I'll try to adapt that code to those commands. > - That loop signaled an error because of an erroneous autoload in > `gnus.el` (it's now fixed in `master`), so your code probably did > not do that. Somehow I never ran into that. > One reason is that for the case of advice, I'd much rather compute the > interactive spec lazily (when the command is called) rather than when > the advice is built. > > Another reason is that there is no dedicated "oclosure slot" for an > interactive-spec. In theory we could use the byte-code object's slot > for that, but making it computable (as needed for bug#51695 and for > advice) would require significant changes to cconv.el and bytecomp.el > (and to make it not too inconvenient to use in `advice.el` it'd > additionally require extending the syntax of `interactive`). > > We could add a dedicated "oclosure slot" for the interactive-spec, but > it'd likely be rather ugly, since that would need to be accessed from > the C in `cmds.c` but would require testing the type of the OClosure > first and that would have to be written in ELisp since it depends on how > OClosure types are represented which itself depends on `cl-defstruct`, > etc... OClosures are records, right? There's no other record type that can be a function with an interactive form, so we could just use `recordp' instead of calling into Lisp for that. Alternatively, we could try to speed up generic dispatch, but I don't know that code and as such am devoid of ideas in that direction. Thanks.