From 634dd48777f5d64611514e01cdd4d7a2d37e5ce5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Kryger?= Date: Tue, 26 Nov 2024 12:07:45 +0000 Subject: [PATCH] fixup! Add newly installed package to load path in exordium-force-elpa --- modules/init-lib.el | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/modules/init-lib.el b/modules/init-lib.el index 3a66adec..e7241a24 100644 --- a/modules/init-lib.el +++ b/modules/init-lib.el @@ -136,12 +136,30 @@ see Info node `(emacs) Package Installation'." (use-package-pin-package package ,archive-name) (condition-case-unless-debug err (let ((package-install-upgrade-built-in t) - (load-path (cons (expand-file-name - (package-desc-full-name archive-desc) - package-user-dir) - load-path))) - (package-install-from-archive archive-desc) - t) + ;; Ensure the newly installed package is in `load-path' + (with-load-path + (lambda (orig-fun &rest args) + (let ((pkg-dir (expand-file-name + (package-desc-full-name archive-desc) + package-user-dir))) + (if (or (member (file-name-as-directory pkg-dir) load-path) + (member (directory-file-name pkg-dir) load-path)) + (apply orig-fun args) + (let ((load-path (cons pkg-dir load-path))) + (apply orig-fun args))))))) + (unwind-protect + (progn + ;; `packgage-activate-1' calls + ;; `package--reload-previously-loaded' before + ;; adding the newly installed package directory to + ;; `load-path'. Ensure the new files are visible. + (advice-add 'package--reload-previously-loaded + :around + with-load-path) + (package-install-from-archive archive-desc) + t) + (advice-remove 'package--reload-previously-loaded + with-load-path))) (error (display-warning 'use-package (format "Failed to force ELPA installation %s: %s"