branch: externals/marginalia commit 1e0c156b0e7931a9aef8ca79dbab0cb690245bcd Author: Daniel Mendler <m...@daniel-mendler.de> Commit: Daniel Mendler <m...@daniel-mendler.de>
marginalia-annotate-theme: Fix autoloading issue Let-binding load-path is a bad idea since it interferes with auto loading. Pass the library path explicitly to marginalia--library-cache instead. --- marginalia.el | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/marginalia.el b/marginalia.el index fb0edf3d69..df56f419da 100644 --- a/marginalia.el +++ b/marginalia.el @@ -1033,8 +1033,9 @@ These annotations are skipped for remote paths." (marginalia-annotate-file (expand-file-name cand root))))) (defvar-local marginalia--library-cache nil) -(defun marginalia--library-cache () - "Return library cache hash table." +(defun marginalia--library-cache (library-path) + "Return hash table from library name to library file. +LIBRARY-PATH is the library search path." (with-current-buffer (if-let (win (active-minibuffer-window)) (window-buffer win) @@ -1044,7 +1045,7 @@ These annotations are skipped for remote paths." (unless marginalia--library-cache (setq marginalia--library-cache (make-hash-table :test #'equal)) ;; Search in reverse because of shadowing - (dolist (dir (reverse load-path)) + (dolist (dir (reverse library-path)) (dolist (file (ignore-errors (directory-files dir 'full "\\.el\\(?:\\.gz\\)?\\'"))) @@ -1089,13 +1090,15 @@ These annotations are skipped for remote paths." (defun marginalia-annotate-theme (cand) "Annotate theme CAND with documentation and path." - (let ((load-path (custom-theme--load-path))) ;; Themes use their own path. - (marginalia-annotate-library (concat cand "-theme")))) + (marginalia-annotate-library (concat cand "-theme") + (custom-theme--load-path))) -(defun marginalia-annotate-library (cand) - "Annotate library CAND with documentation and path." +(defun marginalia-annotate-library (cand &optional library-path) + "Annotate library CAND with documentation and path. +LIBRARY-PATH is the library search path." (setq cand (marginalia--library-name cand)) - (when-let (file (gethash cand (marginalia--library-cache))) + (when-let (file (gethash cand (marginalia--library-cache + (or library-path load-path)))) (marginalia--fields ;; Display if the corresponding feature is loaded. ;; feature/=library file, but better than nothing.