From 9fdfca3265246341ab63fe790b99bd4a2f3cca6d Mon Sep 17 00:00:00 2001 From: James Cherti <60946298+jamescherti@users.noreply.github.com> Date: Sat, 24 Aug 2024 12:36:55 -0400 Subject: [PATCH] Refactor package initialization and refresh logic --- early-init.el | 2 +- init.el | 25 ++++++++++--------------- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/early-init.el b/early-init.el index 71c6c68..5f50d24 100644 --- a/early-init.el +++ b/early-init.el @@ -251,7 +251,7 @@ When set to non-nil, Emacs will automatically call `package-initialize' and ;; on the window system. The variables must also be set to `nil' so users don't ;; have to call the functions twice to re-enable them. (unless (memq 'menu-bar minimal-emacs-ui-features) - (push '(menu-bar-lines . 0) default-frame-alist) + (push '(menu-bar-lines . 0) default-frame-alist) (unless (memq window-system '(mac ns)) (setq menu-bar-mode nil))) diff --git a/init.el b/init.el index 78dee88..d7667de 100644 --- a/init.el +++ b/init.el @@ -18,24 +18,19 @@ (minimal-emacs-load-user-init "pre-init.el") ;;; package.el - (when (bound-and-true-p minimal-emacs-package-initialize-and-refresh) - (let ((package-refresh t)) - ;; Refresh package contents and install `use-package` if necessary - (unless (package-installed-p 'use-package) - (package-refresh-contents t) - (setq package-refresh nil) - (package-install 'use-package)) + ;; Initialize and refresh package contents again if needed + (package-initialize) + (unless package-archive-contents + (package-refresh-contents)) - ;; Ensure `use-package` is available at compile time - (eval-when-compile - (require 'use-package)) + ;; Install use-package if necessary + (unless (package-installed-p 'use-package) + (package-install 'use-package)) - ;; Initialize the package system - (package-initialize) - (when (and package-refresh (not package-archive-contents)) - ;; Refresh package contents again if needed - (package-refresh-contents t)))) + ;; Ensure use-package is available at compile time + (eval-when-compile + (require 'use-package))) ;; Ensure the 'use-package' package is installed and loaded