autoload加载函数,引用了未定义的symbol。

如题:对于autoload的函数中,未定义的symbol, 除了加载整个包文件外,有没有优雅的办法?

你要么没有说清楚自己想做什么,要么没有弄清楚autoload是干嘛的。autoload的函数是一个占位符,在你使用它的时候先load对应的包里的这个文件,然后重定义这个函数,最后运行已经定义好的函数。之后的调用就是直接调用定义好的函数。因此“未定义”的symbol如果是这个包里的,那这个函数运行的时候,这个包已经load了。如果是其他包里的,那其他包应该有对应的autoload。如果这个symbol缺了autoload,比如ref-tex这个包里的函数reftex-parse-all没有autoload,你可以 (autoload #'reftex-parse-all "ref-tex" nil t)

谢谢回复。第一次调用 autoload 函数是 load 整个 autoload 函数所在的文件吗? 这样的话,可能是我使用的 straight 将 autoload 函数抽出到单独文件,在第一次使用这个autoload函数时,就出现了,原包中定义的 var 不被识别,我只好再require这个包文件。

Note that loading a package does not entail invoking require on any of its features. If you wish to actually load the files of the package, you need to do this separately. This is because most packages do not need to be loaded immediately, and are better served by the autoload system.

straight 文档中的关于包的一段描述。

那个……你可能理解错了straight文档里的这段话的意思了。你具体说一下你做了什么

在使用leaf时,我遇到一个leaf-key-bindlist 未定义的错误告警,不知道怎么产生的,require 包,就不存在问题了。以为是autoload 不全部加载包文件导致的。但 autoload也是加载整个包文件。现在看来应该是没有触发autoload加载 leaf 包。谢谢指正。