Skip to content

Commit

Permalink
[dev] print everything
Browse files Browse the repository at this point in the history
  • Loading branch information
pkryger committed Dec 4, 2024
1 parent d6e2090 commit 92e30ce
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions init.el
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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

Expand Down

0 comments on commit 92e30ce

Please sign in to comment.