使用的 dump.el
如下。
;;; Load the whole configuration
(load (expand-file-name "init.el" user-emacs-directory))
;;; Ensure every installed package is loaded.
(dolist (package package-activated-list)
(require package))
;;; We have to unload tramp in pdump, otherwise tramp will not work.
(tramp-unload-tramp)
;;; We use this variable to test if we are starting with dump.
(setq user/dumped-load-path load-path)
;;; Disable GC
(setq gc-cons-threshold most-positive-fixnum
gc-cons-percentage 0.6)
;; dump image
(dump-emacs-portable "~/.emacs.d/emacs.pdmp")
对应的 init.el 中的部分代码如下:
(defvar user/dumped-load-path nil
"Not nil when using dump.")
;;; Some setup for startup with dump
(when user/dumped-load-path
;; Restore the load path
(setq load-path user/dumped-load-path)
;; Disable error message
(setq warning-minimum-level :emergency)
;;; Some shim code for tramp
(defun tramp-file-name-method--cmacro (&rest args))
(require 'tramp)
(setq tramp-mode 1)
;; These two modes are disabled in pdump
(global-font-lock-mode t)
(transient-mark-mode t))
(setq gc-cons-threshold (* 1024 128))
之前使用的是列出一些安装的包,然后不 dump 自己配置。感觉这样维护起来比较麻烦,索性全都 dump 了好了。
启动时间的话看 el 加载要多久已经没有意义了,对比总的加载时间。感觉速度还可以,大概两倍于 emacs -Q。