bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#60568: [FR] 30.0.50; Help buffers and function bodies for generated


From: Stefan Monnier
Subject: bug#60568: [FR] 30.0.50; Help buffers and function bodies for generated functions
Date: Fri, 06 Jan 2023 19:36:04 -0500
User-agent: Gnus/5.13 (Gnus v5.13)

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






reply via email to

[Prev in Thread] Current Thread [Next in Thread]