最近在使用27.0.50的开发版的daily-building 时候发现了 emacs27可以使用early-init.el进行对于已安装的packge的初始化加载设置,原文我是在 emacs的 emacs-news 中看到的,内容如下:
- Startup Changes in Emacs 27.1
+++
** Emacs can now be configured using an early init file. The file is called ‘early-init.el’, in ‘user-emacs-directory’. It is loaded very early in the startup process: before graphical elements such as the tool bar are initialized, and before the package manager is initialized. The primary purpose is to allow customizing how the package system is initialized given that initialization now happens before loading the regular init file (see below).
+++
** Installed packages are now activated before loading the init file. This is part of a change intended to eliminate the behavior of package.el inserting a call to ‘package-initialize’ into the init file, which was previously done when Emacs was started. As a result of this change, it is no longer necessary to call ‘package-initialize’ in your init file.
However, if your init file changes the values of ‘package-load-list’ or ‘package-user-dir’, or sets ‘package-enable-at-startup’ to nil then it won’t work right without some adjustment:
- you can move that code to the early init file (see above), so those settings apply before Emacs tries to activate the packages.
- you can use the new 'package-quickstart` so activation of packages does not need to pay attention to ‘package-load-list’ or ‘package-user-dir’ any more.
我习惯设置 package-user-dir
为其他自定义位置(当然我使用的绝对路径)来方便自己管理elpa包的配置。 于是我按照对原文的理解把这个设置放到了 .emacs.d/early-init.el
中,可是问题来了:
emacs启动时并没有改变其elpa包的集合位置,仍然是默认位置
.emacs.d/elpa
, 这就尴尬了,因为这样一来,emacs就会重新下载所有的包,更无法加载use-package,由于我所有的包都是通过use-package来管理的,这就很不和谐了。
我想请求各位大佬帮助,这个问题怎么解决?
并且我没有使用
package-quickstart
这个把所有autoloads都写到一个文件中以便加速启动的feature。