diff --git a/README.md b/README.md index 7fb4a1d..52f748f 100644 --- a/README.md +++ b/README.md @@ -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. ## Table of Contents diff --git a/early-init.el b/early-init.el index c462db4..f43d019 100644 --- a/early-init.el +++ b/early-init.el @@ -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") diff --git a/init.el b/init.el index 90614b1..52bdf57 100644 --- a/init.el +++ b/init.el @@ -15,6 +15,7 @@ ;;; Code: ;;; Load pre-init.el +(setq minimal-emacs--stage "init.el") (minimal-emacs-load-user-init "pre-init.el") (setq minimal-emacs--stage "init.el")