Include package autoloads in doom-autoloads-file
This offloads some of the work Doom has to do creating `doom-packages-file` onto `make autoloads`. This closely mimics the package-quickstart-refresh functionality in Emacs 27+, but is more specialized. This means package autoloads are now loaded on every startup. Many :mode, :interpreter, and :commands declarations in def-package! blocks are made redundant by this and will be cleaned up soon.
This commit is contained in:
parent
8428a7a4ef
commit
18e6a6b1db
2 changed files with 31 additions and 43 deletions
|
@ -148,15 +148,11 @@ and `auto-mode-alist'.")
|
||||||
"Refresh `doom-packages-file', which caches `load-path',
|
"Refresh `doom-packages-file', which caches `load-path',
|
||||||
`Info-directory-list', `doom-disabled-packages', `auto-mode-alist' and
|
`Info-directory-list', `doom-disabled-packages', `auto-mode-alist' and
|
||||||
`package-activated-list'."
|
`package-activated-list'."
|
||||||
(doom-initialize-packages 'internal)
|
|
||||||
(let ((coding-system-for-write 'emacs-internal))
|
(let ((coding-system-for-write 'emacs-internal))
|
||||||
(with-temp-file doom-packages-file
|
(with-temp-file doom-packages-file
|
||||||
(insert ";;; -*- lexical-binding:t -*-\n"
|
(insert ";;; -*- lexical-binding:t -*-\n"
|
||||||
";; This file was autogenerated by `doom|refresh-cache', DO NOT EDIT!\n")
|
";; This file was autogenerated by `doom|refresh-cache', DO NOT EDIT!\n")
|
||||||
(prin1 `(setq load-path ',load-path
|
(prin1 `(setq Info-directory-list ',Info-directory-list
|
||||||
Info-directory-list ',Info-directory-list
|
|
||||||
auto-mode-alist ',auto-mode-alist
|
|
||||||
interpreter-mode-alist ',interpreter-mode-alist
|
|
||||||
doom-disabled-packages ',doom-disabled-packages
|
doom-disabled-packages ',doom-disabled-packages
|
||||||
package-activated-list ',package-activated-list)
|
package-activated-list ',package-activated-list)
|
||||||
(current-buffer)))))
|
(current-buffer)))))
|
||||||
|
@ -198,6 +194,7 @@ FORCE-P is non-nil, do it anyway.
|
||||||
(require 'subr-x)
|
(require 'subr-x)
|
||||||
(require 'cl-lib)
|
(require 'cl-lib)
|
||||||
(require 'map))
|
(require 'map))
|
||||||
|
(cl-pushnew doom-core-dir load-path :test #'string=)
|
||||||
(when (or force-p (not doom-init-p))
|
(when (or force-p (not doom-init-p))
|
||||||
;; autoloads file
|
;; autoloads file
|
||||||
(unless (load doom-autoload-file 'noerror 'nomessage 'nosuffix)
|
(unless (load doom-autoload-file 'noerror 'nomessage 'nosuffix)
|
||||||
|
@ -234,9 +231,8 @@ FORCE-P is non-nil, do it anyway.
|
||||||
(message "✓ Installed %s" package)
|
(message "✓ Installed %s" package)
|
||||||
(error "✕ Couldn't install %s" package)))
|
(error "✕ Couldn't install %s" package)))
|
||||||
(message "Installing core packages...done")))
|
(message "Installing core packages...done")))
|
||||||
(cl-pushnew doom-core-dir load-path :test #'string=)
|
;; Cache important packages.el state
|
||||||
(add-hook 'doom-internal-init-hook #'doom|refresh-cache))
|
(doom|refresh-cache)
|
||||||
(when doom-debug-mode
|
|
||||||
(message "Doom initialized"))
|
(message "Doom initialized"))
|
||||||
(setq doom-init-p t))
|
(setq doom-init-p t))
|
||||||
;; initialize Doom core
|
;; initialize Doom core
|
||||||
|
@ -439,7 +435,6 @@ MODULES is an malformed plist of modules to load."
|
||||||
(setq doom-modules ',doom-modules)
|
(setq doom-modules ',doom-modules)
|
||||||
,@(nreverse init-forms)
|
,@(nreverse init-forms)
|
||||||
(unless noninteractive
|
(unless noninteractive
|
||||||
(run-hooks 'doom-internal-init-hook)
|
|
||||||
(let ((doom--stage 'config))
|
(let ((doom--stage 'config))
|
||||||
,@(nreverse config-forms)
|
,@(nreverse config-forms)
|
||||||
(when doom-private-dir
|
(when doom-private-dir
|
||||||
|
@ -770,44 +765,41 @@ This should be run whenever init.el or an autoload file is modified. Running
|
||||||
(load-path (append (list doom-emacs-dir)
|
(load-path (append (list doom-emacs-dir)
|
||||||
doom-psuedo-module-dirs
|
doom-psuedo-module-dirs
|
||||||
doom-modules-dirs
|
doom-modules-dirs
|
||||||
load-path))
|
load-path)))
|
||||||
current-sexp)
|
|
||||||
(unwind-protect
|
(unwind-protect
|
||||||
(condition-case-unless-debug ex
|
(condition-case-unless-debug ex
|
||||||
(with-current-buffer buf
|
(with-current-buffer buf
|
||||||
|
(delay-mode-hooks (emacs-lisp-mode))
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
(while (re-search-forward "^\\s-*(" nil t)
|
(insert ";;; -*- lexical-binding:t -*-\n"
|
||||||
(unless (or (nth 4 (syntax-ppss))
|
";; This file is autogenerated by `doom//reload-autoloads', DO NOT EDIT !!\n\n")
|
||||||
(nth 3 (syntax-ppss)))
|
;; insert package autoloads
|
||||||
;; Replace autoload paths with absolute paths for faster
|
(dolist (file (doom-packages--files doom-packages-dir "-autoloads\\.el$"))
|
||||||
;; resolution during load and simpler `load-path'
|
(when doom-debug-mode
|
||||||
(when (memq (sexp-at-point) '(autoload custom-autoload))
|
(message "⚠ Including %s" (file-relative-name file package-user-dir)))
|
||||||
(save-excursion
|
(let ((pfile (prin1-to-string file)))
|
||||||
(forward-sexp 2)
|
(insert "\n(let ((load-file-name " pfile "))")
|
||||||
(let ((pt (point)))
|
(insert-file-contents file)
|
||||||
(forward-sexp 1)
|
(while (re-search-forward "#\\$\\|^;\\(.*\n\\)" nil 'move)
|
||||||
(when-let* ((sexp (thing-at-point 'sexp t))
|
(unless (nth 8 (syntax-ppss))
|
||||||
(path (eval (read sexp) t)))
|
(replace-match (if (match-end 1) "" pfile) t t)))
|
||||||
(when (and (stringp path) (not (file-name-absolute-p path)))
|
(unless (bolp) (insert "\n"))
|
||||||
(delete-region pt (point))
|
(insert ")\n")))
|
||||||
(if-let* ((lib (locate-library path)))
|
(message "✓ Package autoloads included")
|
||||||
(insert " \"" (file-name-sans-extension lib) "\"")
|
|
||||||
(warn "Couldn't find absolute path for: %s" path)))))))
|
(goto-char (point-max))
|
||||||
;; Run each form in autoloads to see if there are any
|
(insert "
|
||||||
;; errors. We do it piecemeal because that will tell us
|
;; Local\sVariables:
|
||||||
;; more about where the issue originated.
|
;; version-control: never
|
||||||
(save-excursion
|
;; no-byte-compile: t
|
||||||
(backward-char)
|
;; no-update-autoloads: t
|
||||||
(setq current-sexp (read (thing-at-point 'sexp t)))
|
;; End:\n")
|
||||||
(eval current-sexp t))
|
(eval-buffer buf)
|
||||||
(forward-char)))
|
|
||||||
(save-buffer)
|
(save-buffer)
|
||||||
(message "Done!"))
|
(message "Done!"))
|
||||||
('error
|
('error
|
||||||
(delete-file doom-autoload-file)
|
(delete-file doom-autoload-file)
|
||||||
(error "Error in autoloads.el: (%s %s ...) %s -- %s"
|
(error "Error in autoloads.el: %s -- %s"
|
||||||
(nth 0 current-sexp)
|
|
||||||
(nth 1 current-sexp)
|
|
||||||
(car ex) (error-message-string ex))))
|
(car ex) (error-message-string ex))))
|
||||||
(kill-buffer buf))))))
|
(kill-buffer buf))))))
|
||||||
|
|
||||||
|
|
|
@ -107,10 +107,6 @@ XDG directory conventions if ~/.config/doom exists.")
|
||||||
(defvar doom-init-hook nil
|
(defvar doom-init-hook nil
|
||||||
"A list of hooks run when DOOM is initialized.")
|
"A list of hooks run when DOOM is initialized.")
|
||||||
|
|
||||||
(defvar doom-internal-init-hook nil
|
|
||||||
"Hooks run after Doom has loaded all init.el files, and is ready to load
|
|
||||||
modules.")
|
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
;; Emacs fixes/hacks
|
;; Emacs fixes/hacks
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue