Force autoloads to use absolute paths
Autoload paths used to be relative to arbitrary roots (usually doom-modules-dir). This commit changes doom//reload-autoloads to iterate over autoloads in doom-autoloads-file and replace their file paths with an absolute one. Theoretically this should make Emacs feel marginally faster, but we *probably* get more of a benefit from a shorter load-path (because we no longer need doom-modules-dirs, doom-core-dir or doom-psuedo-module-paths in the load-path). This is highly experimental however!
This commit is contained in:
parent
1a20c49ef3
commit
a967aa051a
2 changed files with 29 additions and 15 deletions
|
@ -172,11 +172,7 @@ it anyway."
|
||||||
;; Also, in some edge cases involving package initialization during a
|
;; Also, in some edge cases involving package initialization during a
|
||||||
;; non-interactive session, `package-initialize' fails to fill `load-path'.
|
;; non-interactive session, `package-initialize' fails to fill `load-path'.
|
||||||
(setq doom-package-load-path (directory-files package-user-dir t "^[^.]" t)
|
(setq doom-package-load-path (directory-files package-user-dir t "^[^.]" t)
|
||||||
load-path (append doom-package-load-path
|
load-path (append doom-package-load-path doom-site-load-path))))
|
||||||
doom-site-load-path
|
|
||||||
(list doom-core-dir)
|
|
||||||
doom-modules-dirs
|
|
||||||
doom-psuedo-module-dirs))))
|
|
||||||
|
|
||||||
(defun doom-initialize-autoloads ()
|
(defun doom-initialize-autoloads ()
|
||||||
"Ensures that `doom-autoload-file' exists and is loaded. Otherwise run
|
"Ensures that `doom-autoload-file' exists and is loaded. Otherwise run
|
||||||
|
@ -320,7 +316,6 @@ MODULES is an malformed plist of modules to load."
|
||||||
(push `(let (,mod) (load! init ,path t)) init-forms)
|
(push `(let (,mod) (load! init ,path t)) init-forms)
|
||||||
(push `(let (,mod) (load! config ,path t)) config-forms))))))
|
(push `(let (,mod) (load! config ,path t)) config-forms))))))
|
||||||
`(let (file-name-handler-alist)
|
`(let (file-name-handler-alist)
|
||||||
(add-to-list 'load-path ,modules-dir)
|
|
||||||
(setq doom-modules ',doom-modules
|
(setq doom-modules ',doom-modules
|
||||||
doom-modules-dirs ',doom-modules-dirs)
|
doom-modules-dirs ',doom-modules-dirs)
|
||||||
,@(nreverse init-forms)
|
,@(nreverse init-forms)
|
||||||
|
@ -562,7 +557,7 @@ This should be run whenever init.el or an autoload file is modified. Running
|
||||||
;; state. `doom-initialize-packages' will have side effects otherwise.
|
;; state. `doom-initialize-packages' will have side effects otherwise.
|
||||||
(progn
|
(progn
|
||||||
(doom-packages--async-run 'doom//reload-autoloads)
|
(doom-packages--async-run 'doom//reload-autoloads)
|
||||||
(load doom-autoload-file))
|
(load doom-autoload-file t))
|
||||||
(doom-initialize-packages t)
|
(doom-initialize-packages t)
|
||||||
(let ((targets
|
(let ((targets
|
||||||
(file-expand-wildcards
|
(file-expand-wildcards
|
||||||
|
@ -591,18 +586,38 @@ This should be run whenever init.el or an autoload file is modified. Running
|
||||||
(abbreviate-file-name file))))
|
(abbreviate-file-name file))))
|
||||||
(make-directory (file-name-directory doom-autoload-file) t)
|
(make-directory (file-name-directory doom-autoload-file) t)
|
||||||
(let ((buf (find-file-noselect doom-autoload-file t))
|
(let ((buf (find-file-noselect doom-autoload-file t))
|
||||||
|
(load-path (append (list doom-emacs-dir)
|
||||||
|
doom-psuedo-module-dirs
|
||||||
|
doom-modules-dirs))
|
||||||
current-sexp)
|
current-sexp)
|
||||||
(unwind-protect
|
(unwind-protect
|
||||||
(condition-case-unless-debug ex
|
(condition-case-unless-debug ex
|
||||||
(with-current-buffer buf
|
(with-current-buffer buf
|
||||||
(save-buffer)
|
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
(while (re-search-forward "^(" nil t)
|
(while (re-search-forward "^\\s-*(" nil t)
|
||||||
(save-excursion
|
(unless (sp-point-in-string-or-comment)
|
||||||
(backward-char)
|
;; Replace autoload paths with absolute paths for fastest
|
||||||
(setq current-sexp (read (thing-at-point 'sexp t)))
|
;; resolution during load
|
||||||
(eval current-sexp t))
|
(when (eq (sexp-at-point) 'autoload)
|
||||||
(forward-char))
|
(save-excursion
|
||||||
|
(forward-sexp 2)
|
||||||
|
(let ((pt (point)))
|
||||||
|
(forward-sexp 1)
|
||||||
|
(when-let* ((sexp (thing-at-point 'sexp t))
|
||||||
|
(path (eval (read sexp) t)))
|
||||||
|
(delete-region pt (point))
|
||||||
|
(if-let* ((lib (locate-library path)))
|
||||||
|
(insert " \"" (file-name-sans-extension lib) "\"")
|
||||||
|
(warn "Couldn't find absolute path for: %s" path))))))
|
||||||
|
;; Run each form in autoloads to see if there are any
|
||||||
|
;; errors. We do it piecemeal because that will tell us
|
||||||
|
;; more about where the issue originated.
|
||||||
|
(save-excursion
|
||||||
|
(backward-char)
|
||||||
|
(setq current-sexp (read (thing-at-point 'sexp t)))
|
||||||
|
(eval current-sexp t))
|
||||||
|
(forward-char)))
|
||||||
|
(save-buffer)
|
||||||
(message "Finished generating autoloads.el!"))
|
(message "Finished generating autoloads.el!"))
|
||||||
('error
|
('error
|
||||||
(delete-file doom-autoload-file)
|
(delete-file doom-autoload-file)
|
||||||
|
|
|
@ -12,7 +12,6 @@ Doom Emacs.")
|
||||||
;; `doom-initialize-packages' will treat `+private-config-path' as the root of
|
;; `doom-initialize-packages' will treat `+private-config-path' as the root of
|
||||||
;; this module.
|
;; this module.
|
||||||
(add-to-list 'doom-psuedo-module-dirs +private-config-path)
|
(add-to-list 'doom-psuedo-module-dirs +private-config-path)
|
||||||
(add-to-list 'load-path +private-config-path)
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
(load (expand-file-name "init.el" +private-config-path)
|
(load (expand-file-name "init.el" +private-config-path)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue