Commit 07dc62025e29

Vincent Demeester <vincent@sbr.pm>
2020-04-17 19:42:44
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>
1 parent 63d1b23
Changed files (4)
pkgs
scripts
bin
tools
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
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))
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)
.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