维护用户安装的 elisp 的 Emacs 自动加载文件?

发布于 2024-10-10 16:32:38 字数 1132 浏览 10 评论 0原文

Emacs 有这个看似非常好的工具,可以根据 ;;;###autoload 形式的神奇源代码注释(“自动加载 cookies”)构建 autoload 文件,这些文件是单独放置在要自动加载的每个定义上方的行上;请参阅(elisp)自动加载

这似乎是一个理想的工具,用于维护 Emacs 用户最终不可避免地安装在其配置文件中的那些小型单文件包的自动加载。只有一个小问题:这个工具(无论如何,在 GNU Emacs 中)似乎几乎完全专注于为 Emacs 本身生成 loaddefs.el 文件,而对其他用途几乎没有(如果有的话)让步。

这并不能阻止较大的包使用 autoloads.el 机制来构建自己的自动加载文件,但是我看过的那些包有相当多的相当多的代码专门用于使其执行以下操作是必要的,尽管一些毛羽可能是由于 GNU Emacs/XEmacs 的差异造成的。

(我认为 XEmacs 在这方面要好一些,可能至少部分是由于它的官方包系统使用这种机制为每个包制作单独的自动加载文件。希望 GNU Emacs 包含 ELPA 包系统,这也使用这种机制,导致他们方面有类似的改进。)

所以,我的问题是:

我应该如何为目录中的所有 .el 文件维护一个自动加载文件,假设它们具有所有必要的 ;;;###autoload 注释(自动加载 cookies )已经就位了吗?

[唔。块引号在 tex.SE 上看起来很酷...]

我目前正在使用 GNU Emacs 23.2.1,尽管答案越靠后越好。 (就此而言,如果它也能与 XEmacs 一起使用,那就太好了。)

我使用的是 Windows,但 MSYS 与 Emacs 一起安装,因此 sh/bash 脚本可能没问题,只要它们不调用任何可怕的东西异国情调。

[我不完全确定这不属于超级用户而不是SO。如果已经有一个包只需少量配置就可以解决这个问题,那么它可能会这样做;另一方面,如果(正如我怀疑的那样)只有相当粗略的代码片段可能需要大量直接更改,我认为它可能属于这里。]

Emacs has this seemingly very nice facility for building autoload files based on magic source code comments ("autoload cookies") of the form ;;;###autoload, which are to be placed on lines by themselves immediately above each definition to be autoloaded; see (elisp)Autoload.

This would seem to be an ideal tool for maintaining autoloads for those little one-file packages that Emacs users inevitably end up installing in their profiles. There's just one small problem: this facility (in GNU Emacs, anyway) appears to be almost entirely focused on generating the loaddefs.el file for Emacs itself, with very little (if any) concession to other uses.

This doesn't stop largish packages from using the autoloads.el machinery to build their own autoload files, but those that I've looked at have a fair bit of rather hairy code devoted to making it do what is needed, though some of the hairiness might be due to GNU Emacs/XEmacs divergence.

(I think XEmacs is a bit better on this front, probably due at least in part to the fact that its official package system uses this machinery to make separate autoload files for each package. Hopefully GNU Emacs' inclusion of the ELPA package system, which also uses this machinery, leads to similar improvements on their side.)

So, my question for you is:

How should I maintain an autoload file for all .el files in a directory, assuming they have all the necessary ;;;###autoload comments (autoload cookies) in place already?

[Hmm. block quotes look a lot coolor on tex.SE...]

I'm currently using GNU Emacs 23.2.1, though the farther back an answer works, the better. (For that matter, it'd be nice if it would also work with XEmacs.)

I'm on Windows, but have MSYS installed alongside Emacs so sh/bash scripts will probably be fine as long as they don't call anything terribly exotic.

[I'm not entirely certain this doesn't belong on superuser rather than on SO. If there is already a package that can take care of this with only a small amount of configuration, it probably does; on the other hand if (as I suspect) there are only fairly rough snippets of code that might require a good deal of direct changes, I think it probably belongs here on SO.]

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

八巷 2024-10-17 16:32:38

查看这个答案"emacs23 / elisp:如何正确自动加载此库?"

总之,您将所有包转储到特定目录中,并创建您自己的 update-auto-loads.el 包,该包构建 loaddefs.el 并提供您可以随时运行该函数来重建 loaddefs.el 文件。

Check out this answer to "emacs23 / elisp: how to properly autoload this library?".

In summary, you dump all the packages in a particular directory, and create a package of your own update-auto-loads.el, which builds the loaddefs.el and provides a function you can regularly run to rebuild the loaddefs.el file whenever you want.

一萌ing 2024-10-17 16:32:38

2017年,你不用自己维护了。相反,您可以使用现代包管理器,例如 straight.el 它是专门为您处理此问题(以及许多其他事情)而设计的。

您可以使用 package.el 代替 straight.el,但是 package.el 有许多严重的问题,其中一个特别相关的问题是让 package.el 加载您自己编写的本地包是非常尴尬的,特别是 package.el 绝对不支持对包进行修改一旦安装完成。

您也可以使用其他包管理器。我写了一个广泛的部分比较straight.el 到其他包管理器

In 2017, you don't have to maintain it yourself. Instead, you can use a modern package manager such as straight.el which is specifically designed to take care of this (as well as many other things) for you.

You could use package.el instead of straight.el, but package.el has a number of serious problems, and a particularly relevant one is that it's very awkward to get package.el to load a local package you've written yourself, and in particular package.el has absolutely no support for making modifications to a package once it's been installed.

You could use other package managers, as well. I wrote an extensive section comparing straight.el to other package managers.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文