Optimize make autoloads & improve path expansion
Make autoloads will expand the include paths of Doom autoload cookies. This fixes an issue where paths were expanded to include a file extension, bypassing the benefits of byte-compilation.
This commit is contained in:
parent
b4a7e5348a
commit
3e6d7f174a
1 changed files with 47 additions and 25 deletions
|
@ -155,6 +155,7 @@ and `auto-mode-alist'.")
|
||||||
(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 load-path ',load-path
|
||||||
|
auto-mode-alist ',auto-mode-alist
|
||||||
Info-directory-list ',Info-directory-list
|
Info-directory-list ',Info-directory-list
|
||||||
doom-disabled-packages ',doom-disabled-packages
|
doom-disabled-packages ',doom-disabled-packages
|
||||||
package-activated-list ',package-activated-list)
|
package-activated-list ',package-activated-list)
|
||||||
|
@ -742,7 +743,7 @@ This should be run whenever init.el or an autoload file is modified. Running
|
||||||
;; in case this function has side effects.
|
;; in case this function has side effects.
|
||||||
(progn
|
(progn
|
||||||
(doom-packages--async-run 'doom//reload-autoloads)
|
(doom-packages--async-run 'doom//reload-autoloads)
|
||||||
(load doom-autoload-file t nil t))
|
(load doom-autoload-file 'noerror nil 'nosuffix))
|
||||||
(let ((default-directory doom-emacs-dir)
|
(let ((default-directory doom-emacs-dir)
|
||||||
(targets
|
(targets
|
||||||
(file-expand-wildcards
|
(file-expand-wildcards
|
||||||
|
@ -760,7 +761,7 @@ This should be run whenever init.el or an autoload file is modified. Running
|
||||||
(message "Deleted old autoloads.el"))
|
(message "Deleted old autoloads.el"))
|
||||||
(message "Generating new autoloads.el")
|
(message "Generating new autoloads.el")
|
||||||
(dolist (file (mapcar #'file-truename (reverse targets)))
|
(dolist (file (mapcar #'file-truename (reverse targets)))
|
||||||
(let ((generated-autoload-load-name file))
|
(let ((generated-autoload-load-name (file-name-sans-extension file)))
|
||||||
(message
|
(message
|
||||||
(cond ((not (doom-packages--read-if-cookies file))
|
(cond ((not (doom-packages--read-if-cookies file))
|
||||||
"⚠ Ignoring %s")
|
"⚠ Ignoring %s")
|
||||||
|
@ -775,37 +776,58 @@ 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))
|
||||||
|
library-cache)
|
||||||
(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))
|
||||||
(insert ";;; -*- lexical-binding:t -*-\n"
|
(insert ";;; -*- lexical-binding:t -*-\n"
|
||||||
";; This file is autogenerated by `doom//reload-autoloads', DO NOT EDIT !!\n\n")
|
";; This file is autogenerated by `doom//reload-autoloads', DO NOT EDIT !!\n\n")
|
||||||
;; insert package autoloads
|
|
||||||
(dolist (file (doom-packages--files doom-packages-dir "-autoloads\\.el$"))
|
|
||||||
(when doom-debug-mode
|
|
||||||
(message "⚠ Including %s" (file-relative-name file package-user-dir)))
|
|
||||||
(let ((pfile (prin1-to-string file)))
|
|
||||||
(insert "\n(let ((load-file-name " pfile "))")
|
|
||||||
(insert-file-contents file)
|
|
||||||
(while (re-search-forward "#\\$\\|^;\\(.*\n\\)" nil 'move)
|
|
||||||
(unless (nth 8 (syntax-ppss))
|
|
||||||
(replace-match (if (match-end 1) "" pfile) t t)))
|
|
||||||
(unless (bolp) (insert "\n"))
|
|
||||||
(insert ")\n")))
|
|
||||||
(message "✓ Package autoloads included")
|
|
||||||
|
|
||||||
(goto-char (point-max))
|
(save-excursion
|
||||||
(insert "
|
;; Replace autoload paths with absolute paths for faster
|
||||||
;; Local\sVariables:
|
;; resolution during load and simpler `load-path'
|
||||||
;; version-control: never
|
(while (re-search-forward "^\\s-*(autoload\\s-+'[^ ]+\\s-+\"\\([^/][^\"]*\\)\"" nil t)
|
||||||
;; no-byte-compile: t
|
(let ((path (match-string 1)))
|
||||||
;; no-update-autoloads: t
|
;; (delete-region (match-beginning 1) (match-end 1))
|
||||||
;; End:\n")
|
(replace-match
|
||||||
(quiet! (eval-buffer buf))
|
(or (cdr (assoc path library-cache))
|
||||||
|
(when-let* ((libpath (locate-library path))
|
||||||
|
(libpath (file-name-sans-extension libpath)))
|
||||||
|
(push (cons path libpath) library-cache)
|
||||||
|
libpath)
|
||||||
|
(progn
|
||||||
|
(warn "Couldn't find absolute path for: %s" path)
|
||||||
|
path))
|
||||||
|
t t nil 1)))
|
||||||
|
(message "✓ Autoload paths expanded"))
|
||||||
|
|
||||||
|
(save-excursion
|
||||||
|
;; insert package autoloads
|
||||||
|
(dolist (file (doom-packages--files doom-packages-dir "-autoloads\\.el$"))
|
||||||
|
(insert
|
||||||
|
(with-temp-buffer
|
||||||
|
(insert "\n(let ((load-file-name " (prin1-to-string file) "))")
|
||||||
|
(insert-file-contents file)
|
||||||
|
(while (re-search-forward "^;;\\(.*\n\\)" nil 'move)
|
||||||
|
(replace-match "" t t))
|
||||||
|
(unless (bolp) (insert "\n"))
|
||||||
|
(insert ")\n")
|
||||||
|
(buffer-string))))
|
||||||
|
(message "✓ Package autoloads included"))
|
||||||
|
|
||||||
|
;; Replace autoload paths with absolute paths for faster
|
||||||
|
;; resolution during load and simpler `load-path'
|
||||||
|
(while (re-search-forward "^\\s-*(add-to-list\\s-+'\\(?:load-path\\|auto-mode-alist\\)" nil t)
|
||||||
|
(beginning-of-line-text)
|
||||||
|
(kill-sexp))
|
||||||
|
(message "✓ Autoload load-path entries removed")
|
||||||
|
|
||||||
(save-buffer)
|
(save-buffer)
|
||||||
|
(let (byte-compile-warnings)
|
||||||
|
;; give the file a chance to reveal errors
|
||||||
|
(load doom-autoload-file nil 'nomessage 'nosuffix))
|
||||||
(message "Done!"))
|
(message "Done!"))
|
||||||
('error
|
('error
|
||||||
(delete-file doom-autoload-file)
|
(delete-file doom-autoload-file)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue