确保自动加载emacs中的自动加载功能的机制是什么 [英] What's the mechanism to ensure the autoload functions in emacs autoloaded

查看:144
本文介绍了确保自动加载emacs中的自动加载功能的机制是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道所有标记有一行的功能;;; ### Autoload将是一个自动加载的函数,但是问题是排除这个自动加载函数的机制是什么?还有为什么当从elpa安装一个包时,会有一个名为XXX-autoload.elc的编译文件?

I understand all the functions marked with a line ";;;###Autoload" will be an autoloaded function, but the question is what's the mechanism underlying to excute this 'autoloaded function?'. And also why when one installs a package from elpa, there's a compiled file called XXX-autoload.elc?

推荐答案

安装一个Elpa包,Emacs扫描包中的所有.el文件以进行自动加载令牌,并将这些函数/变量的存根添加到[package] -autoloads.el文件中。存根只是将信息附加到功能/变量符号上,告诉Emacs在哪里可以找到实际的定义,以及什么是docstring说的。然后它将所有.el文件编译为.elc文件,包括autoloads文件。

When you install an Elpa package, Emacs scans through all the .el files in the package for autoload tokens and adds stubs for those functions/variables to a [package]-autoloads.el file. The stubs just attach information to the function/variable symbols that tell Emacs where to find the actual definitions, and what the docstring says. Then it compiles all the .el files to .elc files, including the autoloads file.

然后(并且每次启动Emacs),它将加载并评估[package] -autoloads.elc文件,而不是主.elc文件。这样加载软件包的速度要快得多,因为只有当一个自动加载的符号被调用时才会加载主.elc文件。直到那时,Emacs主文件中的其他函数/变量都不知道。

Then (and every time you start Emacs) it loads and evaluates the [package]-autoloads.elc file, rather than the main .elc files. That way it's much faster to load packages, as the main .elc files will only be loaded when one of the autoloaded symbols is invoked. The other functions/variables in the main .el files are not known to Emacs until then.

这篇关于确保自动加载emacs中的自动加载功能的机制是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆