From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: How does one find out what file a library has been loaded from? Date: Sun, 24 Jul 2022 18:37:10 +0300 Message-ID: <83lesifro9.fsf@gnu.org> References: <83sfmxm79z.fsf@gnu.org> <83fsiwncem.fsf@gnu.org> <83mtd3ngcw.fsf@gnu.org> <838rommjxj.fsf@gnu.org> <83k084i1ed.fsf@gnu.org> <83y1wig0y9.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16423"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: acm@muc.de Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Jul 24 17:37:52 2022 Return-path: Envelope-to: ged-emacs-devel@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 1oFdg0-00047E-2w for ged-emacs-devel@m.gmane-mx.org; Sun, 24 Jul 2022 17:37:52 +0200 Original-Received: from localhost ([::1]:37488 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oFdfz-0007U2-1o for ged-emacs-devel@m.gmane-mx.org; Sun, 24 Jul 2022 11:37:51 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49978) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oFdfL-0006jS-Dy for emacs-devel@gnu.org; Sun, 24 Jul 2022 11:37:11 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:60858) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oFdfL-0001rB-2c; Sun, 24 Jul 2022 11:37:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=EIkuhJEqpMSpAnoLdiLMF2ig3lqYm6wTxdj++nOQTrw=; b=qUgatbk0eb/1 0koD+54UZJucD9WO6w2iPR1k2xxcZsdtRx1fo9tN3CEM2XNLL3+sE5UovLSXgZPh+RkFwijiTc4e9 Ue8qQp+lr3Hb+vYNcm9x6V1OuhJQIdFocpgasgUdJ4yeUOARQ1iQBCvF+YD9rrsZ4QfkSP5aoNEzT 0FGcZfyzL6PspEw/FqKJk3lXl/j7xa3VaXpt5vhZyDDI3ThnjEiwoeORpWKTCKk7FkmBLNCNab9Mz xmYf2MutHrmrpBxM/vLC4HVOOxLBEKf22D9RKRbSURMYrjCHriV7SM3ILVAcDutgAULcstRgDwMpI Hz+GxOFpewZmWSU6XGDJyA==; Original-Received: from [87.69.77.57] (port=3376 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oFdfK-0005xX-Iy; Sun, 24 Jul 2022 11:37:10 -0400 In-Reply-To: <83y1wig0y9.fsf@gnu.org> (message from Eli Zaretskii on Sun, 24 Jul 2022 15:16:46 +0300) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:292595 Archived-At: > Date: Sun, 24 Jul 2022 15:16:46 +0300 > From: Eli Zaretskii > Cc: emacs-devel@gnu.org > > In general, you can use load-history or symbol-file to know which file > was loaded. If load-history says it was a .elc file, and the build > supports native compilation, you need to see if the function was > natively-compiled, using > > (subr-native-elisp-p (symbol-function FUNC)) > > where FUNC is a function's symbol. If the above returns non-nil, then > comp-el-to-eln-rel-filename will produce the base name of the .eln > file corresponding to a .el file. > > The above are the building blocks; what's left is to use them in a > particular case. Btw, we could extend symbol-file to support a new kind of TYPE arg, to ask about a natively-compiled symbol, and then we could return the .eln file instead of the .elc file, when appropriate.