【问题标题】:elisp: Is there a way to get the name of the current .el module (like __FILE__ in C)?elisp:有没有办法获取当前 .el 模块的名称(如 C 中的 __FILE__ )?
【发布时间】:2009-12-28 20:19:36
【问题描述】:

在我的 elisp 模块的顶部,我想做一些简单的事情:

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

【问题讨论】:

标签: emacs lisp elisp


【解决方案1】:

可以使用变量load-file-name,由函数load设置,文档如下:

`load' 正在加载的文件的全名。

如手册所述:

当 Emacs 正在加载一个文件时,这个变量的值就是那个文件的名字,正如 Emacs 在本节前面描述的搜索过程中找到的那样。

注意:buffer-file-name 作为例行程序并不像您预期​​的那样工作。

【讨论】:

  • 感谢您完善答案,Trey。我比平时写的更匆忙,并认为早点发布它会有所帮助。
猜你喜欢
  • 2013-09-27
  • 1970-01-01
  • 2010-11-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-08-02
相关资源
最近更新 更多