Skip to content

Commit

Permalink
* core/core-spacemacs.el: enahnce the load-hints to fix #16652
Browse files Browse the repository at this point in the history
  • Loading branch information
sunlin7 authored and smile13241324 committed Nov 13, 2024
1 parent d52d633 commit 2984892
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions core/core-spacemacs.el
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,18 @@ the final step of executing code in `emacs-startup-hook'.")
(cons path (seq-uniq (remove nil bases) 'string-equal))))
load-path))

(define-advice require (:around (func feature &optional filename noerror) LOAD-HINTS)
(if-let* (((and feature (not filename) load-hints))
(path (spacemacs//lookup-load-hints (symbol-name feature))))
(let ((load-path (cons path load-path)))
(funcall func feature filename noerror))
(funcall func feature filename noerror)))
(defun require@LOAD-HINTS (args)
"The advice for `require' function"
(let ((feature (nth 0 args))
(filename (nth 1 args))
(noerror (nth 2 args)))
(when-let* (((and filename load-hints))
(name (symbol-name feature))
(path (spacemacs//lookup-load-hints name)))
(setq filename (expand-file-name name path)))
(list feature filename noerror)))

(advice-add #'require :filter-args #'require@LOAD-HINTS)

(define-advice package-generate-autoloads (:after (name pkg-dir) LOAD-HINTS)
;; if package-enabled-load-hints is non-nil then collecting loadable
Expand Down

0 comments on commit 2984892

Please sign in to comment.