Skip to content

Commit

Permalink
[dbg] print load-path and load-history
Browse files Browse the repository at this point in the history
  • Loading branch information
pkryger committed Dec 6, 2024
1 parent cecac1d commit eecdc8e
Showing 1 changed file with 80 additions and 1 deletion.
81 changes: 80 additions & 1 deletion init.el
Original file line number Diff line number Diff line change
Expand Up @@ -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")))

Expand All @@ -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)

Expand All @@ -183,11 +215,18 @@ melpa-stable.")
(package-refresh-contents)
(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)
Expand All @@ -199,31 +238,41 @@ 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.
(use-package seq
: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.
(use-package org
: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

Expand Down Expand Up @@ -252,6 +301,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
Expand Down Expand Up @@ -340,11 +390,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
Expand All @@ -357,13 +413,16 @@ 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

(exordium-require 'init-prefs) ; Defines variables that prefs.el can override
(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)
Expand All @@ -379,6 +438,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.
Expand All @@ -387,6 +448,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
Expand All @@ -396,6 +459,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))
Expand All @@ -408,6 +473,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

Expand All @@ -419,6 +486,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
Expand All @@ -436,13 +505,17 @@ 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)
(when exordium-yasnippet
(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))
Expand Down Expand Up @@ -477,6 +550,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)
Expand All @@ -496,6 +571,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))
Expand All @@ -505,6 +582,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
Expand Down

0 comments on commit eecdc8e

Please sign in to comment.