From 92e30ce9d31105f18fe725a206ec673917d7a297 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Kryger?= Date: Wed, 4 Dec 2024 08:00:22 +0000 Subject: [PATCH] [dev] print everything --- init.el | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/init.el b/init.el index 58dd8db0..3972d117 100644 --- a/init.el +++ b/init.el @@ -341,6 +341,7 @@ 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)))) + (message "*** Reloading %s" (package-desc-name desc)) (cond ((fboundp 'package--reload-previously-loaded) ;; Since Emacs-29 (package--reload-previously-loaded desc)) @@ -358,6 +359,50 @@ after it's been byte compiled." :after #'exordium--async-package-reload-previously-loaded) (async-bytecomp-package-mode)) +(defun exordium--package--reload-previously-loaded (pkg-desc) + "Force reimportation of files in PKG-DESC already present in `load-history'. +New editions of files contain macro definitions and +redefinitions, the overlooking of which would cause +byte-compilation of the new package to fail." + (with-demoted-errors "Error in package--load-files-for-activation: %s" + (let* (result + (dir (package-desc-dir pkg-desc)) + ;; A previous implementation would skip `dir' itself. + ;; However, in normal use reloading from the same directory + ;; never happens anyway, while in certain cases external to + ;; Emacs a package in the same directory not necessary + ;; stays byte-identical, e.g. during development. Just + ;; don't special-case `dir'. + (effective-path (or (bound-and-true-p find-library-source-path) + load-path)) + (files (directory-files-recursively dir "\\`[^\\.].*\\.el\\'")) + (history (mapcar #'file-truename + (cl-remove-if-not #'stringp + (mapcar #'car load-history))))) + (dolist (file files) + (when-let ((library (package--library-stem + (file-relative-name file dir))) + (canonical (locate-library library nil effective-path)) + (truename (file-truename canonical)) + ;; Normally, all files in a package are compiled by + ;; now, but don't assume that. E.g. different + ;; versions can add or remove `no-byte-compile'. + (altname (if (string-suffix-p ".el" truename) + (replace-regexp-in-string + "\\.el\\'" ".elc" truename t) + (replace-regexp-in-string + "\\.elc\\'" ".el" truename t))) + (found (or (member truename history) + (and (not (string= altname truename)) + (member altname history)))) + (recent-index (length found))) + (unless (equal (file-name-base library) + (format "%s-autoloads" (package-desc-name pkg-desc))) + (push (cons (expand-file-name library dir) recent-index) result)))) + (mapc (lambda (c) (message " --- load %s" (car c))) + (sort result (lambda (x y) (< (cdr x) (cdr y)))))))) +(advice-add 'package--reload-previously-loaded + :before #'exordium--package--reload-previously-loaded) (exordium-require 'init-environment) ; environment variables