From 9a07911859ad21600e1add7a2e51d9501c2b3afa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Kryger?= Date: Fri, 6 Dec 2024 09:52:25 +0000 Subject: [PATCH] [dbg] print load-path and load-history --- init.el | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 80 insertions(+), 1 deletion(-) diff --git a/init.el b/init.el index 968271c4..912ab2a9 100644 --- a/init.el +++ b/init.el @@ -148,6 +148,34 @@ melpa-stable.") (message "Loading tapped before-init file: %s" tapped-file) (load (file-name-sans-extension tapped-file))) +(require 'cl-lib) + +(defvar exordium--dbg-last-load-history nil) +(defvar exordium--dbg-last-load-path nil) + +(defun exordium--dbg-print-load-history-and-path (marker) + "Print all new entries in `load-history' and `load-path'. +Use MARKER to denote where it's been printed from." + (message "[%s] new load-history: %s" + marker + (mapcar #'file-truename + (cl-remove-if-not #'stringp + (mapcar #'car + (cl-subseq load-history + 0 + (cl-position exordium--dbg-last-load-history + load-history)))))) + (setq exordium--dbg-last-load-history (car load-history)) + (message "[%s] new load-path: %s" + marker + (cl-subseq load-path + 0 + (cl-position exordium--dbg-last-load-path + load-path))) + (setq exordium--dbg-last-load-path (car load-path))) + +(exordium--dbg-print-load-history-and-path "init") + (eval-and-compile (load (file-name-concat (locate-user-emacs-file "modules") "init-require"))) @@ -156,9 +184,13 @@ melpa-stable.") ;; Use M-x `package-list-package' to load and display the list of packages, ;; then press I to mark for installation and X to execute (it's like `dired'). +(exordium--dbg-print-load-history-and-path "after init-require") + ;; Initialize the package system (require 'package) +(exordium--dbg-print-load-history-and-path "after package") + (add-to-list 'package-archives (cons "melpa" exordium-melpa-package-repo) t) @@ -187,11 +219,18 @@ melpa-stable.") (package-install-upgrade-built-in t)) (package-install 'use-package)) +(exordium--dbg-print-load-history-and-path "after refresh") + + ;; This is only needed once, near the top of the file (require 'use-package) +(exordium--dbg-print-load-history-and-path "after use-package") + (exordium-require 'init-force-elpa) +(exordium--dbg-print-load-history-and-path "after force-elpa") + ;; Pin user extra packages early, in case they are dependencies of some other ;; packages that are installed early. (dolist (pkg exordium-extra-pinned) @@ -203,6 +242,8 @@ melpa-stable.") (use-package-always-ensure t) (use-package-compute-statistics t)) +(exordium--dbg-print-load-history-and-path "after use-package config") + ;; Some packages (i.e., magit, forge) require relatively new package `seq'. ;; Unfortunately, `package' is unable to bump the built-in `seq'. Ensure it is ;; installed in the newest available version. @@ -210,6 +251,8 @@ melpa-stable.") :defer t :exordium-force-elpa gnu) +(exordium--dbg-print-load-history-and-path "after seq") + ;; `org' may be upgraded from ELPA (for example, as a part of a first start) ;; and some packages depend on it. To prevent loading a built in version by ;; such packages make sure `org' has been upgraded early. @@ -217,17 +260,23 @@ melpa-stable.") :defer t :exordium-force-elpa gnu) +(exordium--dbg-print-load-history-and-path "after org") + (use-package diminish :exordium-force-elpa gnu) (use-package bind-key :exordium-force-elpa gnu) +(exordium--dbg-print-load-history-and-path "after bind-key") + (dolist (pkg (append exordium-extra-packages (mapcar #'car exordium-extra-pinned))) (unless (package-installed-p pkg) (package-install pkg))) + +(exordium--dbg-print-load-history-and-path "after bind-key") ;; Byte recompile modules, if necessary @@ -256,6 +305,7 @@ Also discard .elc without corresponding .el." (delete-file elc))))))) (exordium-recompile-modules) +(exordium--dbg-print-load-history-and-path "after recompile modules") ;; Exordium's CI sometimes signals `ask-user-about-lock' cannot be used in non ;; interactive mode. It used to be that `helm' (and perhaps other packages as @@ -344,11 +394,17 @@ Also remove temp file and relevant entry from This is to mimic what `package-unpack' does: it reloads package after it's been byte compiled." (when-let* ((desc (package-load-descriptor (car args)))) + (exordium--dbg-print-load-history-and-path + (format "before reloading %s" + (package-desc-name desc))) (cond ((fboundp 'package--reload-previously-loaded) ;; Since Emacs-29 (package--reload-previously-loaded desc)) ((fboundp 'package--load-files-for-activation) ;; Until Emacs-28 - (package--load-files-for-activation desc :reload))))) + (package--load-files-for-activation desc :reload))) + (exordium--dbg-print-load-history-and-path + (format "after reloading %s" + (package-desc-name desc))))) :config (advice-add 'async-byte-compile-file @@ -361,6 +417,8 @@ after it's been byte compiled." :after #'exordium--async-package-reload-previously-loaded) (async-bytecomp-package-mode)) +(exordium--dbg-print-load-history-and-path "after async") + ;;; Load Modules @@ -368,6 +426,7 @@ after it's been byte compiled." (exordium-require 'init-lib) ; Utility functions - load this first (exordium-require 'init-environment) ; environment variables +(exordium--dbg-print-load-history-and-path "after environment") (dolist (tapped-file exordium-tapped-prefs-files) (message "Loading tapped prefs file: %s" tapped-file) @@ -383,6 +442,8 @@ after it's been byte compiled." (when exordium-theme (exordium-require 'init-themes)) +(exordium--dbg-print-load-history-and-path "after themes") + ;; Look and feel (exordium-require 'init-look-and-feel) ; fonts, UI, keybindings, saving files etc. (exordium-require 'init-font-lock) ; enables/disables font-lock globally. @@ -391,6 +452,8 @@ after it's been byte compiled." (exordium-require 'init-smooth-scroll) (smooth-scroll-mode 1)) ; smooth scroll +(exordium--dbg-print-load-history-and-path "after smooth-scroll") + (update-progress-bar) ;; Usability @@ -400,6 +463,8 @@ after it's been byte compiled." (exordium-require 'init-ido)) ; supercharged completion engine (exordium-require 'init-highlight) ; highlighting current line, symbol under point +(exordium--dbg-print-load-history-and-path "after highlight") + (pcase exordium-complete-mode (:auto-complete (exordium-require 'init-autocomplete)) @@ -412,6 +477,8 @@ after it's been byte compiled." (when (and exordium-projectile exordium-helm-projectile) (exordium-require 'init-helm-projectile)) +(exordium--dbg-print-load-history-and-path "after helm") + (when exordium-help-extensions (exordium-require 'init-help)) ; extra help @@ -423,6 +490,8 @@ after it's been byte compiled." (exordium-require 'init-forge) ; Forge (exordium-require 'init-flb-mode) ; frame-local buffers +(exordium--dbg-print-load-history-and-path "after flb") + (update-progress-bar) ;; Prog mode @@ -440,6 +509,8 @@ after it's been byte compiled." (when exordium-osx (exordium-require 'init-osx)) +(exordium--dbg-print-load-history-and-path "after osx") + ;; C++ (exordium-require 'init-cpp) (exordium-require 'init-bde-style) @@ -447,6 +518,8 @@ after it's been byte compiled." (exordium-require 'init-yasnippet)) (exordium-require 'init-gdb) +(exordium--dbg-print-load-history-and-path "after gdb") + ;; RTags (exordium-require 'init-rtags nil :functions (rtags-auto-complete)) @@ -481,6 +554,8 @@ after it's been byte compiled." ;; include-what-you-use (exordium-require 'init-iwyu) +(exordium--dbg-print-load-history-and-path "after iwyu") + (update-progress-bar) (when (and exordium-theme exordium-enable-powerline) @@ -500,6 +575,8 @@ after it's been byte compiled." (when exordium-lsp-mode-enable (exordium-require 'init-lsp)) +(exordium--dbg-print-load-history-and-path "after lsp") + ;; Desktop - close to the end so customisations had a chance to kick in (when exordium-desktop (exordium-require 'init-desktop)) @@ -509,6 +586,8 @@ after it's been byte compiled." (message "Loading tapped after-init file: %s" tapped-file) (load (file-name-sans-extension tapped-file))) +(exordium--dbg-print-load-history-and-path "after tapped after-init") + (update-progress-bar) ;; Greetings