From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#60568: [FR] 30.0.50; Help buffers and function bodies for generated functions Date: Fri, 06 Jan 2023 19:36:04 -0500 Message-ID: References: <87fscpifdw.fsf@localhost> <83wn61w7lc.fsf@gnu.org> <8dea9f3e0e7865d8f3c6@heytings.org> <83r0w9vzgy.fsf@gnu.org> <8dea9f3e0e8e6114ffc3@heytings.org> <83pmbtvwyr.fsf@gnu.org> <8dea9f3e0e160e17818f@heytings.org> <83mt6xvsct.fsf@gnu.org> <8dea9f3e0ea1de84c49a@heytings.org> <83cz7sw4q1.fsf@gnu.org> <371ba1d0beb0ed44a9a6@heytings.org> <371ba1d0be96347bdf60@heytings.org> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16238"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 60568@debbugs.gnu.org, yantar92@posteo.net, Eli Zaretskii , mardani29@yahoo.es To: Gregory Heytings Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jan 07 01:37:19 2023 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 1pDxD5-00043R-54 for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 07 Jan 2023 01:37:19 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pDxCz-0007rk-5q; Fri, 06 Jan 2023 19:37:14 -0500 Original-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 1pDxCr-0007qC-CA for bug-gnu-emacs@gnu.org; Fri, 06 Jan 2023 19:37:06 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pDxCo-0006uZ-Uh for bug-gnu-emacs@gnu.org; Fri, 06 Jan 2023 19:37:04 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pDxCo-0000jM-G5 for bug-gnu-emacs@gnu.org; Fri, 06 Jan 2023 19:37:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 07 Jan 2023 00:37:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 60568 X-GNU-PR-Package: emacs Original-Received: via spool by 60568-submit@debbugs.gnu.org id=B60568.16730517772749 (code B ref 60568); Sat, 07 Jan 2023 00:37:02 +0000 Original-Received: (at 60568) by debbugs.gnu.org; 7 Jan 2023 00:36:17 +0000 Original-Received: from localhost ([127.0.0.1]:56167 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pDxC4-0000iG-IL for submit@debbugs.gnu.org; Fri, 06 Jan 2023 19:36:16 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:44223) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pDxC2-0000i2-Ep for 60568@debbugs.gnu.org; Fri, 06 Jan 2023 19:36:14 -0500 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id D0FDB805BA; Fri, 6 Jan 2023 19:36:07 -0500 (EST) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id E8B7580172; Fri, 6 Jan 2023 19:36:05 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1673051765; bh=k+oK9r/LZrEtlcdAqbgdYF9JWOF4xOfb06V8iNfTa7c=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=aqXJ9E/B99KFtJmCrOV890QRyAqE2VI/4PAv/4Qr3gn2NRC7F0iCXxn+wnD8HXfMy /6nRiSom0r0p6Ny0mopnxt2zq4d9a2PT7jvDg2qYHsSIPJE6VPZu1cnlm/hfK4fb9C WcY7tv39iIpI3VxJWlov+oDnhGk0uZV8EweZkxZEmLNiKYHFRibK/lSVAj9t/tX6lx 62fwD9+jhYhHXjzMPYdjaTIQ63M/nCI6ztEaaJk3k8X6oSqys1kWPuVn1q3EovWaEt Zk/kMAb4wtqwbOhboZ7BRpFDArxSQ0kj03bGP1Tk1hNivfiTu/4pydW+9vgD5r8nen flAGpuY92JgAw== Original-Received: from pastel (unknown [45.72.200.228]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id A8F3A120C4B; Fri, 6 Jan 2023 19:36:05 -0500 (EST) In-Reply-To: <371ba1d0be96347bdf60@heytings.org> (Gregory Heytings's message of "Fri, 06 Jan 2023 22:52:32 +0000") 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:252760 Archived-At: >>>>> What about the attached patch? It seems to work well. >>>> SGTM. With which cases did you test this? >>>> Adding Stefan, in case he has any comments. >> SGTM as well. > TBH, I'm not sure this is useful anymore, if the 'definition-name' slot is > supposed to be used for such functions (which I didn't know). WDYT? If you look at the code of `find-func.el` you'll see that we already rely on heuristics, so it seems like a natural complement. But I agree that `definition-name` is usually preferable since it's more reliable. Still most people don't know `definition-name`, so it can still be helpful. >> - We probably want to use `advice-cd*r` so as to flatten the actual >> function definition rather than the combination of its definition with the >> various pieces of advice that are currently applied. > You mean, (flatten-tree (advice--cd*r (symbol-function fun))), right? Yes. >> - The above works for non-compiled functions but for byte-compiled >> functions we need an ad-hoc version of `flatten-tree` which extracts the >> constants from the constant vector of bytecode objects (also recursively >> since bytecode objects tend to contain other bytecode objects). >> >> For native-compiled functions, we may be able to get some kind of >> "constant vector" as well, but I don't think that's currently accessible >> from ELisp. We should ask Andrea. > > Are such dynamically defined functions not always non-compiled, by > definition? No. They can be defined by macros rather than functions in which case they'll usually be compiled. Or they may be closures defined locally within another defun, in which case again they'll usually be compiled. [ E.g. with the patch to `ob-shell.el` that I sent, the `org-babel-execute:sh` is byte-compiled. ] > At least with the original recipe in this feature request, > (symbol-file 'org-babel-execute:sh) returns "lisp/org/ob-shell.elc", so it > has been created by a byte-compiled function. The `ob-shell.el` code in master creates the functions at run time via `eval`, so they're created while loading `ob-shell.elc` but they're interpreted. With my patch, they're just closures so their body is compiled when `ob-shell.el` is compiled. Stefan