elisp: Is there a way to get the name of the current .el module (like __FILE__ in C)?

隐身守侯 提交于 2019-12-04 18:38:48

问题


At the top of my elisp module, I want to do something as simple as:

(message (concat "Loading " (expand-file-name (current-elisp-module) ".")))

回答1:


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.



来源:https://stackoverflow.com/questions/1971349/elisp-is-there-a-way-to-get-the-name-of-the-current-el-module-like-file-i

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!