Control boot sequence by a postpone trick.
I do NOT want to use after-init-hook for configuring some settings or calling functions since it makes Emacs booting so heavy. In order to reduce our stress, some activities while booting up can be postponed after the first user’s action in Emacs. This package provides such postpone capability in three approaches.
This package provides a simple loading mechanism of packages with some delay. The normal function `require’ loads packages when it is evaluated. But if you introduce this minor mode, the associated packages with this mode will be loaded just when you type something for the first time after booting your Emacs. So the loading of associated packages is postponed until you actually start to use Emacs.
Now you just require postpone-pre.el to setup postpone.el. No need to load postpone.el but both files shall be located in load-path. All packages configured within in postpone minor mode will be effected by user action except when commands registered in postpone-pre-exclude are executed. self-insert-command, save-buffers-kill-terminal, and exit-minibuffer are specified in postpone-pre-exclude as default. Please configure postpone-pre-exclude if needed.
(require 'postpone-pre)
(setq postpone-pre-exclude
'(self-insert-command ;; default
newline
forward-char ;; in this case, C-f will not break postpone trick
backward-char
delete-char
delete-backward-char
save-buffer
save-buffers-kill-terminal ;; default
electric-newline-and-maybe-indent
exit-minibuffer))) ;; default
(with-eval-after-load "postpone"
;; Add here any configurations.
;; Or just specify loading init.el here if you put this code to .emacs.
;; All settings in this scope will be postponed
)Note: The following setting is obsoleted (2022-04-19).
Put the following code into your init.el. Just copy and paste :)
(if (not (locate-library "postpone"))
(message "postpone.el is NOT installed.")
(autoload 'postpone-kicker "postpone" nil t)
(defun my:postpone-kicker ()
(interactive)
(unless (memq this-command ;; specify commands for exclusion
'(self-insert-command
save-buffers-kill-terminal
exit-minibuffer))
(postpone-kicker 'my:postpone-kicker)))
(add-hook 'pre-command-hook #'my:postpone-kicker))M-x postpone-init-time will report the initialization time to read postponed settings.
(add-hook 'postpone-mode-hook #'(lambda () (message "Any functions")))(with-eval-after-load "postpone"
;; Any configurations
(setq val1 t))(add-to-list 'postpone-package-list 'org)
(add-to-list 'postpone-package-list 'helm-config)