[Top][All Lists]

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

Re: How does one find out what file a library has been loaded from?

From: T.V Raman
Subject: Re: How does one find out what file a library has been loaded from?
Date: Sun, 24 Jul 2022 08:49:51 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

Stefan Monnier <monnier@iro.umontreal.ca> writes:

In that context, how does find-function work?

>> I just don't understand you saying that the information is still correct.
>> In about "half" the cases, when a .eln file has been loaded, the current
>> text in the Elisp manual and load-history doc string is no longer
>> correct.  The file given in load-history is not the file that was loaded
>> into Emacs.
> Because of the design decision to make native code compilation
> transparent, `load-history` does not mean "this is exactly the file that
> was loaded directly" but rather something like: "this is the file from
> which we loaded the definitions, tho the path to loading them may
> include turning the code into some other representation such a native
> code, while being (hopefully) faithful to the file's semantics".
> So if you actually need to know more precisely where the code comes
> from, you need to look at supplemental information (such as the one
> Andrea gave you).
>>> > > Did you try comp-el-to-eln-filename?
>>> > No.  How could I have known that such a function exists?
>>> I just told you about it.  I told you about it not as an accusation,
>>> but as a way to help you find the best way of solving your problem.
>> OK, thanks.  But I still don't think I could have found out the existence
>> of this function without asing "are there any relevant
>> functions/variables to what I'm trying to do?".
> Which is why your effort to try and document this is worthwhile, indeed.
> [ It may also inform improvements to the API to make it easier to find,
>   but documenting the status quo is an indispensable first step.  ]
>>> Then I think you should describe the purpose better and in more detail.
>> I simply wish to know the file from which a function has been loaded, or
>> the loaded file corresponding to some source file.
> "I" as in "I the human being", and "simply" as in "out of pure curiosity"?
> What are you going to do with that knowledge?  Would you be satisfied
> with knowing only if it's native code rather than byte code (rather
> than see the gory file name with all its hashes and stuff)?
>> I would like to know whether this file is a source file, a .elc, or
>> a .eln.
> `C-h o <function> RET` should tell you that without needing any knowledge
> of ELisp.  Admittedly, it doesn't quite satisfy your requirements since
> the input is now a function name rather than a file name.
>>> What exactly are you trying to accomplish and why?
>> There are lots of reasons I might want to know the loaded file, some of
>> which have already come up in the thread.  I might want to be sure I've
>> built Emacs with native compilation.
> I think the canonical way to test this is
>     (featurep 'native-compile)
>> I might be interested in benchmarking or RAM occupancy.
> I don't see the connection, but `subrp` or `byte-code-function-p` or
> just printing the output of `symbol-function` on a relevant function
> should tell you how your code was compiled.  No need for any file name.
>>> What is the data from which you start and what is the data you want to
>>> obtain as result?
>> The name of a source file or function, and the name of the matching file
>> which was loaded.
> Wanting a "matching file" is IMO the result of your mental model not
> firmed up enough yet, then :-)
> After all, even if the answer is a nasty `.../blabla.eln` you still
> won't know whether your function is implemented as native code since
> that `.eln` can contain (and generate) byte code.  And that's not
> just theory, it does happen in practice.
>         Stefan



--Raman(I Search, I Find, I Misplace, I Research)
?7?4 Id: kg:/m/0285kf1  ?0?8

reply via email to

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