elisp:有没有办法获取当前.el模块的名称(如C中的__FILE__)? [英] elisp: Is there a way to get the name of the current .el module (like __FILE__ in C)?
本文介绍了elisp:有没有办法获取当前.el模块的名称(如C中的__FILE__)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
(message(concatLoading (expand-file-name(current-elisp-module)。))))
解决方案
您可以使用变量 load-file-name
,由 load
,记录如下:
由`load'加载的文件的全名。
如手册中所详述:
当Emacs正在加载一个文件,该变量的值是该文件的名称,正如Emacs在之前描述的搜索过程中发现的那样在这个部分。
注意: buffer-file-name
作为例程不起作用正如你可能期望的那样。
At the top of my elisp module, I want to do something as simple as:
(message (concat "Loading " (expand-file-name (current-elisp-module) ".")))
解决方案
You can use the variable load-file-name
, which is set by the function load
, documented as follows:
Full name of file being loaded by `load'.
As elaborated in the manual:
When Emacs is in the process of loading a file, this variable’s value is the name of that file, as Emacs found it during the search described earlier in this section.
Note: buffer-file-name
as a routine does not work as you might expect it to.
这篇关于elisp:有没有办法获取当前.el模块的名称(如C中的__FILE__)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文