Enhance minimal-emacs--check-success and update README.md
This commit is contained in:
@@ -17,7 +17,7 @@ The author uses *minimal-emacs.d* as his `early-init.el` and `init.el`, alongsid
|
||||
|
||||
*(The theme shown in the screenshot above is the *[tomorrow-night-deepblue-theme.el](https://github.com/jamescherti/tomorrow-night-deepblue-theme.el)*, available on MELPA.)*
|
||||
|
||||
In addition to *minimal-emacs.d*, startup speed is influenced by your computer's processing power and disk speed. To establish a baseline, start Emacs with only *minimal-emacs.d* and no additional configurations, then run `M-x emacs-init-time`. Incrementally modify your init files and observe the impact on startup time. For consistent comparisons, always test on the same computer and Emacs version. It's also important to ensure that all packages are deferred using `:defer t` and `:commands`, which makes Emacs load them only when needed (see additional examples in this README.md).
|
||||
In addition to *minimal-emacs.d*, startup speed is influenced by your computer's processing power and disk speed. To establish a baseline, start Emacs with only *minimal-emacs.d* and no additional configurations, then run `M-x emacs-init-time`. Incrementally modify your init files and observe the impact on startup time. For consistent comparisons, always test on the same computer and Emacs version. It's also important to ensure that all packages are deferred using `:defer t` and `:commands`, which makes Emacs load them only when needed (see additional examples in this README.md). While startup time is important, other factors, like native compilation, are even more important. Although native compilation may introduce some brief initial and negligible initial delay, it is beneficial in the long run as it significantly speeds up Emacs.
|
||||
|
||||
<!-- markdown-toc start - Don't edit this section. Run M-x markdown-toc-refresh-toc -->
|
||||
## Table of Contents
|
||||
|
||||
@@ -32,7 +32,7 @@ turned on.")
|
||||
(defvar minimal-emacs-frame-title-format "%b – Emacs"
|
||||
"Template for displaying the title bar of visible and iconified frame.")
|
||||
|
||||
(defvar minimal-emacs-debug nil
|
||||
(defvar minimal-emacs-debug (bound-and-true-p init-file-debug)
|
||||
"Non-nil to enable debug.")
|
||||
|
||||
(defvar minimal-emacs-gc-cons-threshold (* 16 1024 1024)
|
||||
@@ -71,25 +71,35 @@ minimalistic appearance during startup.")
|
||||
|
||||
;;; Load pre-early-init.el
|
||||
|
||||
;; Prefer loading newer compiled files
|
||||
(setq load-prefer-newer t)
|
||||
|
||||
(defvar minimal-emacs--success nil)
|
||||
(defvar minimal-emacs--stage "early-init.el")
|
||||
(defun minimal-emacs--check-success ()
|
||||
"Verify that the Emacs configuration has loaded successfully."
|
||||
(unless minimal-emacs--success
|
||||
(error (concat "Configuration error in: '%s'. Debug by starting Emacs "
|
||||
"with: emacs --debug-init")
|
||||
minimal-emacs--stage)))
|
||||
(add-hook 'emacs-startup-hook #'minimal-emacs--check-success 102)
|
||||
(cond
|
||||
((let ((user-init-basename (file-name-nondirectory user-init-file)))
|
||||
(and (not (string= user-init-basename "init.el"))
|
||||
(not (string= user-init-basename "early-init.el"))))
|
||||
(error (concat "Emacs ignored loading 'init.el'. Please ensure "
|
||||
"that files such as ~/.emacs or ~/.emacs.el do not exist, "
|
||||
"as they may be preventing Emacs from loading the"
|
||||
" 'init.el' file.")
|
||||
(expand-file-name "init.el" minimal-emacs-user-directory)))
|
||||
|
||||
;; Prefer loading newer compiled files
|
||||
(setq load-prefer-newer t)
|
||||
(error (concat "Configuration error in: '%s'. Debug by starting Emacs "
|
||||
"with: emacs --debug-init")
|
||||
minimal-emacs--stage))))
|
||||
(add-hook 'emacs-startup-hook #'minimal-emacs--check-success 102)
|
||||
|
||||
(defun minimal-emacs-load-user-init (filename)
|
||||
"Execute a file of Lisp code named FILENAME."
|
||||
(let ((init-file (expand-file-name filename
|
||||
minimal-emacs-user-directory)))
|
||||
(when (file-exists-p init-file)
|
||||
(setq minimal-emacs--stage init-file)
|
||||
(setq minimal-emacs--stage (file-name-nondirectory init-file))
|
||||
(load init-file nil t t))))
|
||||
|
||||
(minimal-emacs-load-user-init "pre-early-init.el")
|
||||
|
||||
Reference in New Issue
Block a user