commit 07dc62025e29d8d7ceb8d2fcb43176a976202478
parent 63d1b23937fee06ee08ec4baa41c698e900d77c9
Author: Vincent Demeester <vincent@sbr.pm>
Date: Fri, 17 Apr 2020 19:42:44 +0200
emacs: experiment with portable dump 🦆
- emacs --batch -q -l ~/.config/emacs/dump.el to generate a dump.
- use e or emacs --dump-file=/home/vincent/.config/emacs/emacs.pdmp
This hotload some packages, reducing tremendously the startup
time. From 0.300s to 0.150s.
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
Diffstat:
4 files changed, 44 insertions(+), 2 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -3,4 +3,6 @@ result
hostname
*.retry
assets/machines.nix
-docs/sitemap.org-
\ No newline at end of file
+docs/sitemap.org
+tools/emacs/emacs.pdmp
+tools/emacs/recentf+
\ No newline at end of file
diff --git a/pkgs/scripts/bin/e b/pkgs/scripts/bin/e
@@ -0,0 +1,2 @@
+#!/usr/bin/env bash
+emacs --dump-file=${HOME}/.config/emacs/emacs.pdmp+
\ No newline at end of file
diff --git a/tools/emacs/dump.el b/tools/emacs/dump.el
@@ -0,0 +1,18 @@
+;; -*- lexical-binding: t -*-
+(add-to-list 'load-path (expand-file-name "lisp/" user-emacs-directory))
+(require 'package)
+;; load autoload files and populate load-path’s
+(setq sbr-dumped-load-path load-path
+ sbr-dumped t)
+(package-initialize)
+;; (package-initialize) doens’t require each package, we need to load
+;; those we want manually
+(dolist (package '(use-package company recentf moody helpful undo-tree cus-edit pinentry hardhat diff
+ use-package aggressive-indent savehist minions expand-region time uniquify isearch
+ minibuffer icomplete dired delsel direnv auth-source simple epa-file message
+ vc vc-dir vc-git region-bindings-mode
+ shortbrain-light-theme shortbrain-theme))
+ (require package))
+(load-theme 'shortbrain-light t t)
+;; dump image
+(dump-emacs-portable (expand-file-name "emacs.pdmp" user-emacs-directory))
diff --git a/tools/emacs/init.el b/tools/emacs/init.el
@@ -2,6 +2,25 @@
;;; Commentary:
;;; init configuration file for GNU Emacs
;;; Code:
+
+(defvar sbr-dumped nil
+ "non-nil when a dump file is loaded (because dump.el sets this variable).")
+
+(defmacro sbr-if-dump (then &rest else)
+ "Evaluate IF if running with a dump file, else evaluate ELSE."
+ (declare (indent 1))
+ `(if sbr-dumped
+ ,then
+ ,@else))
+
+(sbr-if-dump
+ (progn
+ (setq load-path sbr-dumped-load-path)
+ (global-font-lock-mode)
+ (transient-mark-mode))
+ ;; add load-path’s and load autoload files
+ (package-initialize))
+
;; +CheckVer
(let ((minver 26))
(unless (>= emacs-major-version minver)