From d17039f2357f8474773c97065b0a95b9e21d615e Mon Sep 17 00:00:00 2001 From: James Cherti <60946298+jamescherti@users.noreply.github.com> Date: Wed, 12 Mar 2025 16:24:35 -0400 Subject: [PATCH 1/7] Make minimal-emacs-load-user-init also load .elc or .eln files --- README.md | 4 ++-- early-init.el | 4 ++-- init.el | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 12c6043..7ed7755 100644 --- a/README.md +++ b/README.md @@ -1107,7 +1107,7 @@ To prioritize MELPA over MELPA Stable, to access bleeding-edge package versions, Add the following line to the end of your `post-init.el` file: ```lisp -(minimal-emacs-load-user-init "local.el") +(minimal-emacs-load-user-init "local") ``` This allows `local.el` to load, enabling custom configurations specific to the machine. @@ -1147,7 +1147,7 @@ Add the following to the top of the `~/.emacs.d/pre-early-init.el` file to make (unless (string= minimal-emacs-user-directory previous-minimal-emacs-user-directory) ;; Load pre-early-init.el from the new directory - (minimal-emacs-load-user-init "pre-early-init.el"))) + (minimal-emacs-load-user-init "pre-early-init"))) ``` ### Are post-early-init.el and pre-init.el the same file in terms of the logic? diff --git a/early-init.el b/early-init.el index 7675277..158e9c7 100644 --- a/early-init.el +++ b/early-init.el @@ -100,7 +100,7 @@ When set to non-nil, Emacs will automatically call `package-initialize' and (setq minimal-emacs--stage (file-name-nondirectory init-file)) (load init-file nil t)))) -(minimal-emacs-load-user-init "pre-early-init.el") +(minimal-emacs-load-user-init "pre-early-init") (setq minimal-emacs--stage "early-init.el") (setq custom-theme-directory @@ -398,7 +398,7 @@ this stage of initialization." ("melpa" . 0))) ;;; Load post-early-init.el -(minimal-emacs-load-user-init "post-early-init.el") +(minimal-emacs-load-user-init "post-early-init") (provide 'early-init) diff --git a/init.el b/init.el index 166de01..5a3d11a 100644 --- a/init.el +++ b/init.el @@ -1,4 +1,4 @@ -;;; init.el --- Init -*- lexical-binding: t; -*- +;;; init.el --- Init -*- no-byte-compile: t; lexical-binding: t; -*- ;; Author: James Cherti ;; URL: https://github.com/jamescherti/minimal-emacs.d @@ -17,7 +17,7 @@ ;;; Load pre-init.el (setq minimal-emacs--stage "init.el") (if (fboundp 'minimal-emacs-load-user-init) - (minimal-emacs-load-user-init "pre-init.el") + (minimal-emacs-load-user-init "pre-init") (error "The early-init.el file failed to loaded")) (setq minimal-emacs--stage "init.el") @@ -518,7 +518,7 @@ ;;; Load post init (when (fboundp 'minimal-emacs-load-user-init) - (minimal-emacs-load-user-init "post-init.el")) + (minimal-emacs-load-user-init "post-init")) (setq minimal-emacs--success t) (provide 'init) From 383f61046d68e72407ac0443190adc4065e91936 Mon Sep 17 00:00:00 2001 From: James Cherti <60946298+jamescherti@users.noreply.github.com> Date: Wed, 12 Mar 2025 16:44:11 -0400 Subject: [PATCH 2/7] Simplify minimal-emacs-load-user-init --- early-init.el | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/early-init.el b/early-init.el index 158e9c7..9f9c906 100644 --- a/early-init.el +++ b/early-init.el @@ -94,11 +94,9 @@ When set to non-nil, Emacs will automatically call `package-initialize' and (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 (file-name-nondirectory init-file)) - (load init-file nil t)))) + (let* ((init-file (expand-file-name filename + minimal-emacs-user-directory))) + (load init-file :no-error :no-message))) (minimal-emacs-load-user-init "pre-early-init") (setq minimal-emacs--stage "early-init.el") From 10f65a60b1032dde93366c1c6bf6e00f5b49bdf0 Mon Sep 17 00:00:00 2001 From: James Cherti <60946298+jamescherti@users.noreply.github.com> Date: Wed, 12 Mar 2025 16:46:30 -0400 Subject: [PATCH 3/7] Remove minimal-emacs--stage --- early-init.el | 12 +++--------- init.el | 2 -- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/early-init.el b/early-init.el index 9f9c906..dd0c238 100644 --- a/early-init.el +++ b/early-init.el @@ -75,21 +75,16 @@ When set to non-nil, Emacs will automatically call `package-initialize' and (setq debug-on-error minimal-emacs-debug) (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 (cond - ((and (or (string= minimal-emacs--stage "pre-early-init.el") - (string= minimal-emacs--stage "early-init.el") - (string= minimal-emacs--stage "post-early-init.el")) - (or (file-exists-p (expand-file-name "~/.emacs.el")) - (file-exists-p (expand-file-name "~/.emacs")))) + ((or (file-exists-p (expand-file-name "~/.emacs.el")) + (file-exists-p (expand-file-name "~/.emacs"))) (error "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")) (t - (error "Configuration error in: '%s'. Debug by starting Emacs with: emacs --debug-init" - minimal-emacs--stage))))) + (error "Configuration error. Debug by starting Emacs with: emacs --debug-init"))))) (add-hook 'emacs-startup-hook #'minimal-emacs--check-success 102) (defun minimal-emacs-load-user-init (filename) @@ -99,7 +94,6 @@ When set to non-nil, Emacs will automatically call `package-initialize' and (load init-file :no-error :no-message))) (minimal-emacs-load-user-init "pre-early-init") -(setq minimal-emacs--stage "early-init.el") (setq custom-theme-directory (expand-file-name "themes/" minimal-emacs-user-directory)) diff --git a/init.el b/init.el index 5a3d11a..315a8ba 100644 --- a/init.el +++ b/init.el @@ -15,11 +15,9 @@ ;;; Code: ;;; Load pre-init.el -(setq minimal-emacs--stage "init.el") (if (fboundp 'minimal-emacs-load-user-init) (minimal-emacs-load-user-init "pre-init") (error "The early-init.el file failed to loaded")) -(setq minimal-emacs--stage "init.el") ;;; Before package From 1b72f7bb2a9004ed5267103b10ab71f87157d932 Mon Sep 17 00:00:00 2001 From: James Cherti <60946298+jamescherti@users.noreply.github.com> Date: Wed, 12 Mar 2025 17:00:27 -0400 Subject: [PATCH 4/7] Remove eval-when-compile for require use-package --- init.el | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/init.el b/init.el index 315a8ba..fba12f4 100644 --- a/init.el +++ b/init.el @@ -50,8 +50,7 @@ (package-install 'use-package)) ;; Ensure use-package is available - (eval-when-compile - (require 'use-package))) + (require 'use-package)) ;;; Features, warnings, and errors From 90c996e118a1fd2e93c2fdbc52f2b2f8a6db7c78 Mon Sep 17 00:00:00 2001 From: James Cherti <60946298+jamescherti@users.noreply.github.com> Date: Wed, 12 Mar 2025 17:07:54 -0400 Subject: [PATCH 5/7] Only run package-refresh-contents when necessary --- init.el | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/init.el b/init.el index fba12f4..ff95ffb 100644 --- a/init.el +++ b/init.el @@ -42,11 +42,10 @@ (when (bound-and-true-p minimal-emacs-package-initialize-and-refresh) ;; Initialize and refresh package contents again if needed (package-initialize) - (unless (seq-empty-p package-archive-contents) - (package-refresh-contents)) - ;; Install use-package if necessary (unless (package-installed-p 'use-package) + (unless (seq-empty-p package-archive-contents) + (package-refresh-contents)) (package-install 'use-package)) ;; Ensure use-package is available From 9eb2a138ec0e4c11ba66f03b4f15c4134f442960 Mon Sep 17 00:00:00 2001 From: James Cherti <60946298+jamescherti@users.noreply.github.com> Date: Wed, 12 Mar 2025 17:18:28 -0400 Subject: [PATCH 6/7] Remove MELPA stable --- early-init.el | 2 -- 1 file changed, 2 deletions(-) diff --git a/early-init.el b/early-init.el index dd0c238..4bb3150 100644 --- a/early-init.el +++ b/early-init.el @@ -381,12 +381,10 @@ this stage of initialization." (setq use-package-always-ensure t) (setq use-package-enable-imenu-support t) (setq package-archives '(("melpa" . "https://melpa.org/packages/") - ("melpa-stable" . "https://stable.melpa.org/packages/") ("gnu" . "https://elpa.gnu.org/packages/") ("nongnu" . "https://elpa.nongnu.org/nongnu/"))) (customize-set-variable 'package-archive-priorities '(("gnu" . 99) ("nongnu" . 80) - ("melpa-stable" . 70) ("melpa" . 0))) ;;; Load post-early-init.el From e0e1d04ae672804cd57ea354a629033d0cd8010b Mon Sep 17 00:00:00 2001 From: James Cherti <60946298+jamescherti@users.noreply.github.com> Date: Wed, 12 Mar 2025 17:26:01 -0400 Subject: [PATCH 7/7] Update README.md --- README.md | 33 +++++---------------------------- early-init.el | 1 + 2 files changed, 6 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 7ed7755..80a40c0 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ In addition to *minimal-emacs.d*, startup speed is influenced by your computer's - [Configuring elpaca (package manager)](#configuring-elpaca-package-manager) - [Frequently asked questions](#frequently-asked-questions) - [How to display Emacs startup duration?](#how-to-display-emacs-startup-duration) - - [How to give more priority to MELPA over MELPA stable?](#how-to-give-more-priority-to-melpa-over-melpa-stable) + - [How to use MELPA stable?](#how-to-use-melpa-stable) - [How to load a local lisp file for machine-specific configurations?](#how-to-load-a-local-lisp-file-for-machine-specific-configurations) - [How to load Emacs customizations?](#how-to-load-emacs-customizations) - [How to increase gc-cons-threshold?](#how-to-increase-gc-cons-threshold) @@ -1070,38 +1070,15 @@ Add the following to your `~/.emacs.d/pre-early-init.el` file: (Alternatively, you may use the built-in `M-x emacs-init-time` command to obtain the startup duration. However, `emacs-init-time` does not account for the portion of the startup process that occurs after `after-init-time`.) -### How to give more priority to MELPA over MELPA stable? +### How to use MELPA stable? -**Warning:** MELPA Stable is generally more reliable and thoroughly tested, as it contains stable versions of packages. On the other hand, MELPA provides bleeding-edge versions, which often include new features but may also introduce changes that could potentially break functionality. The author of *minimal-emacs.d* uses MELPA over MELPA Stable without encountering issues, but this is provided as a caution to allow you to make an informed decision based on your stability versus feature needs. - -By default, the *minimal-emacs.d* configuration assigns specific priorities to various package archives, which determines the order in which packages are fetched from these archives. The default priorities are as follows: +To add MELPA Stable for accessing stable package versions, you can adjust the `package-archive-priorities` variable in your `~/.emacs.d/post-early-init.el` file. ```elisp -(customize-set-variable 'package-archive-priorities '(("gnu" . 99) - ("nongnu" . 80) - ("melpa-stable" . 70) - ("melpa" . 0))) +(push '("melpa-stable" . "https://stable.melpa.org/packages/") package-archives) ``` -In this configuration, the GNU, Nongnu, and MELPA Stable archives (which contain stable versions of MELPA packages) are assigned higher priorities than MELPA (which contains the latest versions of packages). As a result, packages will be fetched from MELPA Stable before MELPA. - -To prioritize MELPA over MELPA Stable, to access bleeding-edge package versions, you can adjust the `package-archive-priorities` variable accordingly: - -```elisp -;; This change increases MELPA's priority to 75, above MELPA Stable's -;; priority of 70, ensuring that MELPA is preferred for package installations -;; over MELPA Stable. -;; -;; MELPA Stable offers reliable, tested versions, while MELPA provides newer -;; features at the risk of potential instability; for your information, -;; the author of minimal-emacs.d has been using MELPA (and not MELPA stable) -;; for years without any major issues. -(customize-set-variable 'package-archive-priorities '(("gnu" . 99) - ("nongnu" . 80) - ("melpa-stable" . 70) - ;; MELPA priority has been changed to 75 - ("melpa" . 75))) -``` +However, the packages can sometimes be outdated. ### How to load a local lisp file for machine-specific configurations? diff --git a/early-init.el b/early-init.el index 4bb3150..17ab580 100644 --- a/early-init.el +++ b/early-init.el @@ -385,6 +385,7 @@ this stage of initialization." ("nongnu" . "https://elpa.nongnu.org/nongnu/"))) (customize-set-variable 'package-archive-priorities '(("gnu" . 99) ("nongnu" . 80) + ("melpa-stable" . 70) ("melpa" . 0))) ;;; Load post-early-init.el