04 Mar 2023 -
Emacs has the ability to dump its whole program state to a file on disk and recover from it.
I’m taking advantage of that and dumping a pre-configured Emacs. Startup times get much faster.
This is the implementation of my dump-emacs
command:
;; Fixes load-path issues
(defun dump-load-path ()
(with-temp-buffer
(insert (prin1-to-string `(setq load-path ',load-path)))
(fill-region (point-min) (point-max))
(write-file "~/.emacs.d/load-path.el")))
(defun dump-emacs ()
"Dump current Emacs config."
(interactive)
(shell-command "emacs-snapshot --batch -l ~/.emacs -eval '(dump-load-path)' -eval '(dump-emacs-portable \"~/emacs.dump\")'"))
After running dump-emacs
, an ~/emacs.dump
file with the current Emacs configuration is created.
To start from the dump, use: emacs -q --dump-file emacs.dump