doomemacs/core/cli/byte-compile.el

198 lines
8.6 KiB
EmacsLisp
Raw Normal View History

;;; core/cli/byte-compile.el -*- lexical-binding: t; -*-
(defcli! (compile c)
((recompile-p ["-r" "--recompile"])
Backport bits of CLI rewrite The rewrite for Doom's CLI is taking a while, so I've backported a few important changes in order to ease the transition and fix a couple bugs sooner. Fixes #2802, #2737, #2386 The big highlights are: - Fix #2802: We now update recipe repos *before* updating/installing any new packages. No more "Could not find package X in recipe repositories". - Fix #2737: An edge case where straight couldn't reach a pinned commit (particularly with agda). - Doom is now smarter about what option it recommends when straight prompts you to make a choice. - Introduces a new init path for Doom. The old way: - Launch in "minimal" CLI mode in non-interactive sessions - Launch a "full" interactive mode otherwise. The new way - Launch in "minimal" CLI mode *only* for bin/doom - Launch is a simple mode for non-interactive sessions that still need access to your interactive config (like async org export/babel). - Launch a "full" interactive mode otherwise. This should fix compatibility issues with plugins that use the async.el library or spawn child Emacs processes to fake parallelization (like org's async export and babel functionality). - Your private init.el is now loaded more reliably when running any bin/doom command. This gives you an opportunity to configure its settings. - Added doom-first-{input,buffer,file}-hook hooks, which we use to queue deferred activation of a number of packages. Users can remove these modes from these hooks; altogether preventing them from loading, rather than waiting for them to load to then disable them, e.g. (after! smartparens (smartparens-global-mode -1)) -> (remove-hook 'doom-first-buffer #'smartparens-global-mode) Hooks added to doom-first-*-hook variables will be removed once they run. This should also indirectly fix #2386, by preventing interactive modes from running in non-interactive session. - Added `doom/bump-*` commands to make bumping modules and packages easier, and `doom/bumpify-*` commands for converting package! statements into user/repo@sha1hash format for bump commits. - straight.el is now commit-pinned, like all other packages. We also more reliably install straight.el by cloning it ourselves, rather than relying on its bootstrap.el. This should prevent infinite "straight has diverged from master" prompts whenever we change branches (though, you might have to put up with it one more after this update -- see #2937 for workaround). All the other minor changes: - Moved core/autoload/cli.el to core/autoload/process.el - The package manager will log attempts to check out pinned commits - If package state is incomplete while rebuilding packages, emit a simpler error message instead of an obscure one! - Added -u switch to 'doom sync' to make it run 'doom update' afterwards - Added -p switch to 'doom sync' to make it run 'doom purge' afterwards - Replace doom-modules function with doom-modules-list - The `with-plist!` macro was removed, since `cl-destructuring-bind` already serves that purpose well enough. - core/autoload/packages.el was moved into core-packages.el - bin/doom will no longer die if DOOMDIR or DOOMLOCALDIR don't have a trailing slash - Introduces doom-debug-variables; a list of variables to toggle on doom/toggle-debug-mode. - The sandbox has been updated to reflect the above changes, also: 1. Child instances will no longer inherit the process environment of the host instance, 2. It will no longer produce an auto-save-list directory in ~/.emacs.d
2020-05-15 03:00:23 +08:00
(core-p ["-c" "--core"])
(private-p ["-p" "--private"])
(verbose-p ["-v" "--verbose"]))
"Byte-compiles your config or selected modules.
compile [TARGETS...]
compile :core :private lang/python
compile feature lang
Accepts :core and :private as special arguments, which target Doom's core files
and your private config files, respectively. To recompile your packages, use
Backport bits of CLI rewrite The rewrite for Doom's CLI is taking a while, so I've backported a few important changes in order to ease the transition and fix a couple bugs sooner. Fixes #2802, #2737, #2386 The big highlights are: - Fix #2802: We now update recipe repos *before* updating/installing any new packages. No more "Could not find package X in recipe repositories". - Fix #2737: An edge case where straight couldn't reach a pinned commit (particularly with agda). - Doom is now smarter about what option it recommends when straight prompts you to make a choice. - Introduces a new init path for Doom. The old way: - Launch in "minimal" CLI mode in non-interactive sessions - Launch a "full" interactive mode otherwise. The new way - Launch in "minimal" CLI mode *only* for bin/doom - Launch is a simple mode for non-interactive sessions that still need access to your interactive config (like async org export/babel). - Launch a "full" interactive mode otherwise. This should fix compatibility issues with plugins that use the async.el library or spawn child Emacs processes to fake parallelization (like org's async export and babel functionality). - Your private init.el is now loaded more reliably when running any bin/doom command. This gives you an opportunity to configure its settings. - Added doom-first-{input,buffer,file}-hook hooks, which we use to queue deferred activation of a number of packages. Users can remove these modes from these hooks; altogether preventing them from loading, rather than waiting for them to load to then disable them, e.g. (after! smartparens (smartparens-global-mode -1)) -> (remove-hook 'doom-first-buffer #'smartparens-global-mode) Hooks added to doom-first-*-hook variables will be removed once they run. This should also indirectly fix #2386, by preventing interactive modes from running in non-interactive session. - Added `doom/bump-*` commands to make bumping modules and packages easier, and `doom/bumpify-*` commands for converting package! statements into user/repo@sha1hash format for bump commits. - straight.el is now commit-pinned, like all other packages. We also more reliably install straight.el by cloning it ourselves, rather than relying on its bootstrap.el. This should prevent infinite "straight has diverged from master" prompts whenever we change branches (though, you might have to put up with it one more after this update -- see #2937 for workaround). All the other minor changes: - Moved core/autoload/cli.el to core/autoload/process.el - The package manager will log attempts to check out pinned commits - If package state is incomplete while rebuilding packages, emit a simpler error message instead of an obscure one! - Added -u switch to 'doom sync' to make it run 'doom update' afterwards - Added -p switch to 'doom sync' to make it run 'doom purge' afterwards - Replace doom-modules function with doom-modules-list - The `with-plist!` macro was removed, since `cl-destructuring-bind` already serves that purpose well enough. - core/autoload/packages.el was moved into core-packages.el - bin/doom will no longer die if DOOMDIR or DOOMLOCALDIR don't have a trailing slash - Introduces doom-debug-variables; a list of variables to toggle on doom/toggle-debug-mode. - The sandbox has been updated to reflect the above changes, also: 1. Child instances will no longer inherit the process environment of the host instance, 2. It will no longer produce an auto-save-list directory in ~/.emacs.d
2020-05-15 03:00:23 +08:00
'doom build' instead."
(doom-cli-byte-compile
(if (or core-p private-p)
(append (when core-p
(list (doom-glob doom-emacs-dir "init.el")
doom-core-dir))
(when private-p
(list doom-private-dir)))
(append (list (doom-glob doom-emacs-dir "init.el")
doom-core-dir)
(cl-remove-if-not
;; Only compile Doom's modules
(lambda (path) (file-in-directory-p path doom-emacs-dir))
;; Omit `doom-private-dir', which is always first
(cdr (doom-module-load-path)))))
recompile-p
verbose-p))
(defcli! clean ()
"Delete all *.elc files."
:bare t
(doom-clean-byte-compiled-files))
;;
;; Helpers
(defun doom--byte-compile-ignore-file-p (path)
(let ((filename (file-name-nondirectory path)))
Backport bits of CLI rewrite The rewrite for Doom's CLI is taking a while, so I've backported a few important changes in order to ease the transition and fix a couple bugs sooner. Fixes #2802, #2737, #2386 The big highlights are: - Fix #2802: We now update recipe repos *before* updating/installing any new packages. No more "Could not find package X in recipe repositories". - Fix #2737: An edge case where straight couldn't reach a pinned commit (particularly with agda). - Doom is now smarter about what option it recommends when straight prompts you to make a choice. - Introduces a new init path for Doom. The old way: - Launch in "minimal" CLI mode in non-interactive sessions - Launch a "full" interactive mode otherwise. The new way - Launch in "minimal" CLI mode *only* for bin/doom - Launch is a simple mode for non-interactive sessions that still need access to your interactive config (like async org export/babel). - Launch a "full" interactive mode otherwise. This should fix compatibility issues with plugins that use the async.el library or spawn child Emacs processes to fake parallelization (like org's async export and babel functionality). - Your private init.el is now loaded more reliably when running any bin/doom command. This gives you an opportunity to configure its settings. - Added doom-first-{input,buffer,file}-hook hooks, which we use to queue deferred activation of a number of packages. Users can remove these modes from these hooks; altogether preventing them from loading, rather than waiting for them to load to then disable them, e.g. (after! smartparens (smartparens-global-mode -1)) -> (remove-hook 'doom-first-buffer #'smartparens-global-mode) Hooks added to doom-first-*-hook variables will be removed once they run. This should also indirectly fix #2386, by preventing interactive modes from running in non-interactive session. - Added `doom/bump-*` commands to make bumping modules and packages easier, and `doom/bumpify-*` commands for converting package! statements into user/repo@sha1hash format for bump commits. - straight.el is now commit-pinned, like all other packages. We also more reliably install straight.el by cloning it ourselves, rather than relying on its bootstrap.el. This should prevent infinite "straight has diverged from master" prompts whenever we change branches (though, you might have to put up with it one more after this update -- see #2937 for workaround). All the other minor changes: - Moved core/autoload/cli.el to core/autoload/process.el - The package manager will log attempts to check out pinned commits - If package state is incomplete while rebuilding packages, emit a simpler error message instead of an obscure one! - Added -u switch to 'doom sync' to make it run 'doom update' afterwards - Added -p switch to 'doom sync' to make it run 'doom purge' afterwards - Replace doom-modules function with doom-modules-list - The `with-plist!` macro was removed, since `cl-destructuring-bind` already serves that purpose well enough. - core/autoload/packages.el was moved into core-packages.el - bin/doom will no longer die if DOOMDIR or DOOMLOCALDIR don't have a trailing slash - Introduces doom-debug-variables; a list of variables to toggle on doom/toggle-debug-mode. - The sandbox has been updated to reflect the above changes, also: 1. Child instances will no longer inherit the process environment of the host instance, 2. It will no longer produce an auto-save-list directory in ~/.emacs.d
2020-05-15 03:00:23 +08:00
(or (not (equal (file-name-extension path) "el"))
(member filename (list "packages.el" "doctor.el"))
(string-prefix-p "." filename)
(string-prefix-p "test-" filename)
Backport bits of CLI rewrite The rewrite for Doom's CLI is taking a while, so I've backported a few important changes in order to ease the transition and fix a couple bugs sooner. Fixes #2802, #2737, #2386 The big highlights are: - Fix #2802: We now update recipe repos *before* updating/installing any new packages. No more "Could not find package X in recipe repositories". - Fix #2737: An edge case where straight couldn't reach a pinned commit (particularly with agda). - Doom is now smarter about what option it recommends when straight prompts you to make a choice. - Introduces a new init path for Doom. The old way: - Launch in "minimal" CLI mode in non-interactive sessions - Launch a "full" interactive mode otherwise. The new way - Launch in "minimal" CLI mode *only* for bin/doom - Launch is a simple mode for non-interactive sessions that still need access to your interactive config (like async org export/babel). - Launch a "full" interactive mode otherwise. This should fix compatibility issues with plugins that use the async.el library or spawn child Emacs processes to fake parallelization (like org's async export and babel functionality). - Your private init.el is now loaded more reliably when running any bin/doom command. This gives you an opportunity to configure its settings. - Added doom-first-{input,buffer,file}-hook hooks, which we use to queue deferred activation of a number of packages. Users can remove these modes from these hooks; altogether preventing them from loading, rather than waiting for them to load to then disable them, e.g. (after! smartparens (smartparens-global-mode -1)) -> (remove-hook 'doom-first-buffer #'smartparens-global-mode) Hooks added to doom-first-*-hook variables will be removed once they run. This should also indirectly fix #2386, by preventing interactive modes from running in non-interactive session. - Added `doom/bump-*` commands to make bumping modules and packages easier, and `doom/bumpify-*` commands for converting package! statements into user/repo@sha1hash format for bump commits. - straight.el is now commit-pinned, like all other packages. We also more reliably install straight.el by cloning it ourselves, rather than relying on its bootstrap.el. This should prevent infinite "straight has diverged from master" prompts whenever we change branches (though, you might have to put up with it one more after this update -- see #2937 for workaround). All the other minor changes: - Moved core/autoload/cli.el to core/autoload/process.el - The package manager will log attempts to check out pinned commits - If package state is incomplete while rebuilding packages, emit a simpler error message instead of an obscure one! - Added -u switch to 'doom sync' to make it run 'doom update' afterwards - Added -p switch to 'doom sync' to make it run 'doom purge' afterwards - Replace doom-modules function with doom-modules-list - The `with-plist!` macro was removed, since `cl-destructuring-bind` already serves that purpose well enough. - core/autoload/packages.el was moved into core-packages.el - bin/doom will no longer die if DOOMDIR or DOOMLOCALDIR don't have a trailing slash - Introduces doom-debug-variables; a list of variables to toggle on doom/toggle-debug-mode. - The sandbox has been updated to reflect the above changes, also: 1. Child instances will no longer inherit the process environment of the host instance, 2. It will no longer produce an auto-save-list directory in ~/.emacs.d
2020-05-15 03:00:23 +08:00
(string-prefix-p "flycheck_" filename)
(string-suffix-p ".example.el" filename))))
Backport bits of CLI rewrite The rewrite for Doom's CLI is taking a while, so I've backported a few important changes in order to ease the transition and fix a couple bugs sooner. Fixes #2802, #2737, #2386 The big highlights are: - Fix #2802: We now update recipe repos *before* updating/installing any new packages. No more "Could not find package X in recipe repositories". - Fix #2737: An edge case where straight couldn't reach a pinned commit (particularly with agda). - Doom is now smarter about what option it recommends when straight prompts you to make a choice. - Introduces a new init path for Doom. The old way: - Launch in "minimal" CLI mode in non-interactive sessions - Launch a "full" interactive mode otherwise. The new way - Launch in "minimal" CLI mode *only* for bin/doom - Launch is a simple mode for non-interactive sessions that still need access to your interactive config (like async org export/babel). - Launch a "full" interactive mode otherwise. This should fix compatibility issues with plugins that use the async.el library or spawn child Emacs processes to fake parallelization (like org's async export and babel functionality). - Your private init.el is now loaded more reliably when running any bin/doom command. This gives you an opportunity to configure its settings. - Added doom-first-{input,buffer,file}-hook hooks, which we use to queue deferred activation of a number of packages. Users can remove these modes from these hooks; altogether preventing them from loading, rather than waiting for them to load to then disable them, e.g. (after! smartparens (smartparens-global-mode -1)) -> (remove-hook 'doom-first-buffer #'smartparens-global-mode) Hooks added to doom-first-*-hook variables will be removed once they run. This should also indirectly fix #2386, by preventing interactive modes from running in non-interactive session. - Added `doom/bump-*` commands to make bumping modules and packages easier, and `doom/bumpify-*` commands for converting package! statements into user/repo@sha1hash format for bump commits. - straight.el is now commit-pinned, like all other packages. We also more reliably install straight.el by cloning it ourselves, rather than relying on its bootstrap.el. This should prevent infinite "straight has diverged from master" prompts whenever we change branches (though, you might have to put up with it one more after this update -- see #2937 for workaround). All the other minor changes: - Moved core/autoload/cli.el to core/autoload/process.el - The package manager will log attempts to check out pinned commits - If package state is incomplete while rebuilding packages, emit a simpler error message instead of an obscure one! - Added -u switch to 'doom sync' to make it run 'doom update' afterwards - Added -p switch to 'doom sync' to make it run 'doom purge' afterwards - Replace doom-modules function with doom-modules-list - The `with-plist!` macro was removed, since `cl-destructuring-bind` already serves that purpose well enough. - core/autoload/packages.el was moved into core-packages.el - bin/doom will no longer die if DOOMDIR or DOOMLOCALDIR don't have a trailing slash - Introduces doom-debug-variables; a list of variables to toggle on doom/toggle-debug-mode. - The sandbox has been updated to reflect the above changes, also: 1. Child instances will no longer inherit the process environment of the host instance, 2. It will no longer produce an auto-save-list directory in ~/.emacs.d
2020-05-15 03:00:23 +08:00
(cl-defun doom-cli-byte-compile (&optional targets recompile-p verbose-p)
"Byte compiles your emacs configuration.
init.el is always byte-compiled by this.
Backport bits of CLI rewrite The rewrite for Doom's CLI is taking a while, so I've backported a few important changes in order to ease the transition and fix a couple bugs sooner. Fixes #2802, #2737, #2386 The big highlights are: - Fix #2802: We now update recipe repos *before* updating/installing any new packages. No more "Could not find package X in recipe repositories". - Fix #2737: An edge case where straight couldn't reach a pinned commit (particularly with agda). - Doom is now smarter about what option it recommends when straight prompts you to make a choice. - Introduces a new init path for Doom. The old way: - Launch in "minimal" CLI mode in non-interactive sessions - Launch a "full" interactive mode otherwise. The new way - Launch in "minimal" CLI mode *only* for bin/doom - Launch is a simple mode for non-interactive sessions that still need access to your interactive config (like async org export/babel). - Launch a "full" interactive mode otherwise. This should fix compatibility issues with plugins that use the async.el library or spawn child Emacs processes to fake parallelization (like org's async export and babel functionality). - Your private init.el is now loaded more reliably when running any bin/doom command. This gives you an opportunity to configure its settings. - Added doom-first-{input,buffer,file}-hook hooks, which we use to queue deferred activation of a number of packages. Users can remove these modes from these hooks; altogether preventing them from loading, rather than waiting for them to load to then disable them, e.g. (after! smartparens (smartparens-global-mode -1)) -> (remove-hook 'doom-first-buffer #'smartparens-global-mode) Hooks added to doom-first-*-hook variables will be removed once they run. This should also indirectly fix #2386, by preventing interactive modes from running in non-interactive session. - Added `doom/bump-*` commands to make bumping modules and packages easier, and `doom/bumpify-*` commands for converting package! statements into user/repo@sha1hash format for bump commits. - straight.el is now commit-pinned, like all other packages. We also more reliably install straight.el by cloning it ourselves, rather than relying on its bootstrap.el. This should prevent infinite "straight has diverged from master" prompts whenever we change branches (though, you might have to put up with it one more after this update -- see #2937 for workaround). All the other minor changes: - Moved core/autoload/cli.el to core/autoload/process.el - The package manager will log attempts to check out pinned commits - If package state is incomplete while rebuilding packages, emit a simpler error message instead of an obscure one! - Added -u switch to 'doom sync' to make it run 'doom update' afterwards - Added -p switch to 'doom sync' to make it run 'doom purge' afterwards - Replace doom-modules function with doom-modules-list - The `with-plist!` macro was removed, since `cl-destructuring-bind` already serves that purpose well enough. - core/autoload/packages.el was moved into core-packages.el - bin/doom will no longer die if DOOMDIR or DOOMLOCALDIR don't have a trailing slash - Introduces doom-debug-variables; a list of variables to toggle on doom/toggle-debug-mode. - The sandbox has been updated to reflect the above changes, also: 1. Child instances will no longer inherit the process environment of the host instance, 2. It will no longer produce an auto-save-list directory in ~/.emacs.d
2020-05-15 03:00:23 +08:00
If TARGETS is specified, as a list of direcotries
If MODULES is specified (a list of module strings, e.g. \"lang/php\"), those are
byte-compiled. Otherwise, all enabled modules are byte-compiled, including Doom
core. It always ignores unit tests and files with `no-byte-compile' enabled.
WARNING: byte-compilation yields marginal gains and makes debugging new issues
difficult. It is recommended you don't use it unless you understand the
reprecussions.
Use `doom-clean-byte-compiled-files' or `make clean' to reverse
byte-compilation.
If RECOMPILE-P is non-nil, only recompile out-of-date files."
Backport bits of CLI rewrite The rewrite for Doom's CLI is taking a while, so I've backported a few important changes in order to ease the transition and fix a couple bugs sooner. Fixes #2802, #2737, #2386 The big highlights are: - Fix #2802: We now update recipe repos *before* updating/installing any new packages. No more "Could not find package X in recipe repositories". - Fix #2737: An edge case where straight couldn't reach a pinned commit (particularly with agda). - Doom is now smarter about what option it recommends when straight prompts you to make a choice. - Introduces a new init path for Doom. The old way: - Launch in "minimal" CLI mode in non-interactive sessions - Launch a "full" interactive mode otherwise. The new way - Launch in "minimal" CLI mode *only* for bin/doom - Launch is a simple mode for non-interactive sessions that still need access to your interactive config (like async org export/babel). - Launch a "full" interactive mode otherwise. This should fix compatibility issues with plugins that use the async.el library or spawn child Emacs processes to fake parallelization (like org's async export and babel functionality). - Your private init.el is now loaded more reliably when running any bin/doom command. This gives you an opportunity to configure its settings. - Added doom-first-{input,buffer,file}-hook hooks, which we use to queue deferred activation of a number of packages. Users can remove these modes from these hooks; altogether preventing them from loading, rather than waiting for them to load to then disable them, e.g. (after! smartparens (smartparens-global-mode -1)) -> (remove-hook 'doom-first-buffer #'smartparens-global-mode) Hooks added to doom-first-*-hook variables will be removed once they run. This should also indirectly fix #2386, by preventing interactive modes from running in non-interactive session. - Added `doom/bump-*` commands to make bumping modules and packages easier, and `doom/bumpify-*` commands for converting package! statements into user/repo@sha1hash format for bump commits. - straight.el is now commit-pinned, like all other packages. We also more reliably install straight.el by cloning it ourselves, rather than relying on its bootstrap.el. This should prevent infinite "straight has diverged from master" prompts whenever we change branches (though, you might have to put up with it one more after this update -- see #2937 for workaround). All the other minor changes: - Moved core/autoload/cli.el to core/autoload/process.el - The package manager will log attempts to check out pinned commits - If package state is incomplete while rebuilding packages, emit a simpler error message instead of an obscure one! - Added -u switch to 'doom sync' to make it run 'doom update' afterwards - Added -p switch to 'doom sync' to make it run 'doom purge' afterwards - Replace doom-modules function with doom-modules-list - The `with-plist!` macro was removed, since `cl-destructuring-bind` already serves that purpose well enough. - core/autoload/packages.el was moved into core-packages.el - bin/doom will no longer die if DOOMDIR or DOOMLOCALDIR don't have a trailing slash - Introduces doom-debug-variables; a list of variables to toggle on doom/toggle-debug-mode. - The sandbox has been updated to reflect the above changes, also: 1. Child instances will no longer inherit the process environment of the host instance, 2. It will no longer produce an auto-save-list directory in ~/.emacs.d
2020-05-15 03:00:23 +08:00
(let* ((default-directory doom-emacs-dir)
(targets (nreverse (delete-dups targets)))
;; In case it is changed during compile-time
(auto-mode-alist auto-mode-alist)
kill-emacs-hook kill-buffer-query-functions)
(let ((after-load-functions
(if (null targets)
after-load-functions
;; Assemble el files we want to compile, and preserve in the order
;; they are loaded in, so we don't run into any scary catch-22s
;; while byte-compiling, like missing macros.
(cons (let ((target-dirs (cl-remove-if-not #'file-directory-p targets)))
(lambda (path)
(and (not (doom--byte-compile-ignore-file-p path))
(cl-find-if (doom-partial #'file-in-directory-p path)
target-dirs)
(cl-pushnew path targets))))
after-load-functions))))
(doom-log "Reloading Doom in preparation for byte-compilation")
;; But first we must be sure that Doom and your private config have been
;; fully loaded. Which usually aren't so in an noninteractive session.
Backport bits of CLI rewrite The rewrite for Doom's CLI is taking a while, so I've backported a few important changes in order to ease the transition and fix a couple bugs sooner. Fixes #2802, #2737, #2386 The big highlights are: - Fix #2802: We now update recipe repos *before* updating/installing any new packages. No more "Could not find package X in recipe repositories". - Fix #2737: An edge case where straight couldn't reach a pinned commit (particularly with agda). - Doom is now smarter about what option it recommends when straight prompts you to make a choice. - Introduces a new init path for Doom. The old way: - Launch in "minimal" CLI mode in non-interactive sessions - Launch a "full" interactive mode otherwise. The new way - Launch in "minimal" CLI mode *only* for bin/doom - Launch is a simple mode for non-interactive sessions that still need access to your interactive config (like async org export/babel). - Launch a "full" interactive mode otherwise. This should fix compatibility issues with plugins that use the async.el library or spawn child Emacs processes to fake parallelization (like org's async export and babel functionality). - Your private init.el is now loaded more reliably when running any bin/doom command. This gives you an opportunity to configure its settings. - Added doom-first-{input,buffer,file}-hook hooks, which we use to queue deferred activation of a number of packages. Users can remove these modes from these hooks; altogether preventing them from loading, rather than waiting for them to load to then disable them, e.g. (after! smartparens (smartparens-global-mode -1)) -> (remove-hook 'doom-first-buffer #'smartparens-global-mode) Hooks added to doom-first-*-hook variables will be removed once they run. This should also indirectly fix #2386, by preventing interactive modes from running in non-interactive session. - Added `doom/bump-*` commands to make bumping modules and packages easier, and `doom/bumpify-*` commands for converting package! statements into user/repo@sha1hash format for bump commits. - straight.el is now commit-pinned, like all other packages. We also more reliably install straight.el by cloning it ourselves, rather than relying on its bootstrap.el. This should prevent infinite "straight has diverged from master" prompts whenever we change branches (though, you might have to put up with it one more after this update -- see #2937 for workaround). All the other minor changes: - Moved core/autoload/cli.el to core/autoload/process.el - The package manager will log attempts to check out pinned commits - If package state is incomplete while rebuilding packages, emit a simpler error message instead of an obscure one! - Added -u switch to 'doom sync' to make it run 'doom update' afterwards - Added -p switch to 'doom sync' to make it run 'doom purge' afterwards - Replace doom-modules function with doom-modules-list - The `with-plist!` macro was removed, since `cl-destructuring-bind` already serves that purpose well enough. - core/autoload/packages.el was moved into core-packages.el - bin/doom will no longer die if DOOMDIR or DOOMLOCALDIR don't have a trailing slash - Introduces doom-debug-variables; a list of variables to toggle on doom/toggle-debug-mode. - The sandbox has been updated to reflect the above changes, also: 1. Child instances will no longer inherit the process environment of the host instance, 2. It will no longer produce an auto-save-list directory in ~/.emacs.d
2020-05-15 03:00:23 +08:00
(let ((load-prefer-newer t)
(noninteractive t)
doom-interactive-p)
Backport bits of CLI rewrite The rewrite for Doom's CLI is taking a while, so I've backported a few important changes in order to ease the transition and fix a couple bugs sooner. Fixes #2802, #2737, #2386 The big highlights are: - Fix #2802: We now update recipe repos *before* updating/installing any new packages. No more "Could not find package X in recipe repositories". - Fix #2737: An edge case where straight couldn't reach a pinned commit (particularly with agda). - Doom is now smarter about what option it recommends when straight prompts you to make a choice. - Introduces a new init path for Doom. The old way: - Launch in "minimal" CLI mode in non-interactive sessions - Launch a "full" interactive mode otherwise. The new way - Launch in "minimal" CLI mode *only* for bin/doom - Launch is a simple mode for non-interactive sessions that still need access to your interactive config (like async org export/babel). - Launch a "full" interactive mode otherwise. This should fix compatibility issues with plugins that use the async.el library or spawn child Emacs processes to fake parallelization (like org's async export and babel functionality). - Your private init.el is now loaded more reliably when running any bin/doom command. This gives you an opportunity to configure its settings. - Added doom-first-{input,buffer,file}-hook hooks, which we use to queue deferred activation of a number of packages. Users can remove these modes from these hooks; altogether preventing them from loading, rather than waiting for them to load to then disable them, e.g. (after! smartparens (smartparens-global-mode -1)) -> (remove-hook 'doom-first-buffer #'smartparens-global-mode) Hooks added to doom-first-*-hook variables will be removed once they run. This should also indirectly fix #2386, by preventing interactive modes from running in non-interactive session. - Added `doom/bump-*` commands to make bumping modules and packages easier, and `doom/bumpify-*` commands for converting package! statements into user/repo@sha1hash format for bump commits. - straight.el is now commit-pinned, like all other packages. We also more reliably install straight.el by cloning it ourselves, rather than relying on its bootstrap.el. This should prevent infinite "straight has diverged from master" prompts whenever we change branches (though, you might have to put up with it one more after this update -- see #2937 for workaround). All the other minor changes: - Moved core/autoload/cli.el to core/autoload/process.el - The package manager will log attempts to check out pinned commits - If package state is incomplete while rebuilding packages, emit a simpler error message instead of an obscure one! - Added -u switch to 'doom sync' to make it run 'doom update' afterwards - Added -p switch to 'doom sync' to make it run 'doom purge' afterwards - Replace doom-modules function with doom-modules-list - The `with-plist!` macro was removed, since `cl-destructuring-bind` already serves that purpose well enough. - core/autoload/packages.el was moved into core-packages.el - bin/doom will no longer die if DOOMDIR or DOOMLOCALDIR don't have a trailing slash - Introduces doom-debug-variables; a list of variables to toggle on doom/toggle-debug-mode. - The sandbox has been updated to reflect the above changes, also: 1. Child instances will no longer inherit the process environment of the host instance, 2. It will no longer produce an auto-save-list directory in ~/.emacs.d
2020-05-15 03:00:23 +08:00
(doom-initialize 'force)
(quiet! (doom-initialize-packages))))
(if (null targets)
(print! (info "No targets to %scompile" (if recompile-p "re" "")))
(print! (start "%scompiling your config...")
(if recompile-p "Re" "Byte-"))
(dolist (dir
(cl-remove-if-not #'file-directory-p targets)
(setq targets (cl-remove-if #'file-directory-p targets)))
(prependq! targets
(doom-files-in
dir :match "\\.el" :filter #'doom--byte-compile-ignore-file-p)))
(print-group!
(require 'use-package)
(condition-case-unless-debug e
(let* ((total-ok 0)
(total-fail 0)
(total-noop 0)
(byte-compile-verbose nil)
(byte-compile-warnings '(not free-vars unresolved noruntime lexical make-local))
(byte-compile-dynamic-docstrings t)
(use-package-compute-statistics nil)
(use-package-defaults use-package-defaults)
(use-package-expand-minimally t)
(targets (delete-dups targets))
(modules (seq-group-by #'doom-module-from-path targets))
Backport bits of CLI rewrite The rewrite for Doom's CLI is taking a while, so I've backported a few important changes in order to ease the transition and fix a couple bugs sooner. Fixes #2802, #2737, #2386 The big highlights are: - Fix #2802: We now update recipe repos *before* updating/installing any new packages. No more "Could not find package X in recipe repositories". - Fix #2737: An edge case where straight couldn't reach a pinned commit (particularly with agda). - Doom is now smarter about what option it recommends when straight prompts you to make a choice. - Introduces a new init path for Doom. The old way: - Launch in "minimal" CLI mode in non-interactive sessions - Launch a "full" interactive mode otherwise. The new way - Launch in "minimal" CLI mode *only* for bin/doom - Launch is a simple mode for non-interactive sessions that still need access to your interactive config (like async org export/babel). - Launch a "full" interactive mode otherwise. This should fix compatibility issues with plugins that use the async.el library or spawn child Emacs processes to fake parallelization (like org's async export and babel functionality). - Your private init.el is now loaded more reliably when running any bin/doom command. This gives you an opportunity to configure its settings. - Added doom-first-{input,buffer,file}-hook hooks, which we use to queue deferred activation of a number of packages. Users can remove these modes from these hooks; altogether preventing them from loading, rather than waiting for them to load to then disable them, e.g. (after! smartparens (smartparens-global-mode -1)) -> (remove-hook 'doom-first-buffer #'smartparens-global-mode) Hooks added to doom-first-*-hook variables will be removed once they run. This should also indirectly fix #2386, by preventing interactive modes from running in non-interactive session. - Added `doom/bump-*` commands to make bumping modules and packages easier, and `doom/bumpify-*` commands for converting package! statements into user/repo@sha1hash format for bump commits. - straight.el is now commit-pinned, like all other packages. We also more reliably install straight.el by cloning it ourselves, rather than relying on its bootstrap.el. This should prevent infinite "straight has diverged from master" prompts whenever we change branches (though, you might have to put up with it one more after this update -- see #2937 for workaround). All the other minor changes: - Moved core/autoload/cli.el to core/autoload/process.el - The package manager will log attempts to check out pinned commits - If package state is incomplete while rebuilding packages, emit a simpler error message instead of an obscure one! - Added -u switch to 'doom sync' to make it run 'doom update' afterwards - Added -p switch to 'doom sync' to make it run 'doom purge' afterwards - Replace doom-modules function with doom-modules-list - The `with-plist!` macro was removed, since `cl-destructuring-bind` already serves that purpose well enough. - core/autoload/packages.el was moved into core-packages.el - bin/doom will no longer die if DOOMDIR or DOOMLOCALDIR don't have a trailing slash - Introduces doom-debug-variables; a list of variables to toggle on doom/toggle-debug-mode. - The sandbox has been updated to reflect the above changes, also: 1. Child instances will no longer inherit the process environment of the host instance, 2. It will no longer produce an auto-save-list directory in ~/.emacs.d
2020-05-15 03:00:23 +08:00
(total-files (length targets))
(total-modules (length modules))
(i 0)
last-module)
;; Prevent packages from being loaded at compile time if they
;; don't meet their own predicates.
(push (list :no-require t
(lambda (_name args)
(or (when-let (pred (or (plist-get args :if)
(plist-get args :when)))
(not (eval pred t)))
(when-let (pred (plist-get args :unless))
(eval pred t)))))
use-package-defaults)
(dolist (module-files modules)
(cl-incf i)
(dolist (target (cdr module-files))
(let ((elc-file (byte-compile-dest-file target)))
(cl-incf
(if (and recompile-p (not (file-newer-than-file-p target elc-file)))
total-noop
(pcase (if (not (doom-file-cookie-p target "if" t))
'no-byte-compile
(unless (equal last-module (car module-files))
(print! (success "(% 3d/%d) Compiling %s %s module...")
i total-modules (caar module-files) (cdar module-files))
(setq last-module (car module-files)))
(if verbose-p
(byte-compile-file target)
(quiet! (byte-compile-file target))))
(`no-byte-compile
(print! (debug "(% 3d/%d) Ignored %s")
i total-modules (relpath target))
total-noop)
(`nil
(print! (error "(% 3d/%d) Failed to compile %s")
i total-modules (relpath target))
total-fail)
(_ total-ok)))))))
(print! (class (if (= total-fail 0) 'success 'warn)
"%s %d/%d file(s) (%d ignored)")
(if recompile-p "Recompiled" "Byte-compiled")
total-ok total-files
total-noop)
(= total-fail 0))
((debug error)
(print! (error "There were breaking errors.\n\n%s")
"Reverting changes...")
(signal 'doom-error (list 'byte-compile e))))))))
(defun doom-clean-byte-compiled-files ()
"Delete all the compiled elc files in your Emacs configuration and private
module. This does not include your byte-compiled, third party packages.'"
(require 'core-modules)
(print! (start "Cleaning .elc files"))
(print-group!
(cl-loop with default-directory = doom-emacs-dir
Backport bits of CLI rewrite The rewrite for Doom's CLI is taking a while, so I've backported a few important changes in order to ease the transition and fix a couple bugs sooner. Fixes #2802, #2737, #2386 The big highlights are: - Fix #2802: We now update recipe repos *before* updating/installing any new packages. No more "Could not find package X in recipe repositories". - Fix #2737: An edge case where straight couldn't reach a pinned commit (particularly with agda). - Doom is now smarter about what option it recommends when straight prompts you to make a choice. - Introduces a new init path for Doom. The old way: - Launch in "minimal" CLI mode in non-interactive sessions - Launch a "full" interactive mode otherwise. The new way - Launch in "minimal" CLI mode *only* for bin/doom - Launch is a simple mode for non-interactive sessions that still need access to your interactive config (like async org export/babel). - Launch a "full" interactive mode otherwise. This should fix compatibility issues with plugins that use the async.el library or spawn child Emacs processes to fake parallelization (like org's async export and babel functionality). - Your private init.el is now loaded more reliably when running any bin/doom command. This gives you an opportunity to configure its settings. - Added doom-first-{input,buffer,file}-hook hooks, which we use to queue deferred activation of a number of packages. Users can remove these modes from these hooks; altogether preventing them from loading, rather than waiting for them to load to then disable them, e.g. (after! smartparens (smartparens-global-mode -1)) -> (remove-hook 'doom-first-buffer #'smartparens-global-mode) Hooks added to doom-first-*-hook variables will be removed once they run. This should also indirectly fix #2386, by preventing interactive modes from running in non-interactive session. - Added `doom/bump-*` commands to make bumping modules and packages easier, and `doom/bumpify-*` commands for converting package! statements into user/repo@sha1hash format for bump commits. - straight.el is now commit-pinned, like all other packages. We also more reliably install straight.el by cloning it ourselves, rather than relying on its bootstrap.el. This should prevent infinite "straight has diverged from master" prompts whenever we change branches (though, you might have to put up with it one more after this update -- see #2937 for workaround). All the other minor changes: - Moved core/autoload/cli.el to core/autoload/process.el - The package manager will log attempts to check out pinned commits - If package state is incomplete while rebuilding packages, emit a simpler error message instead of an obscure one! - Added -u switch to 'doom sync' to make it run 'doom update' afterwards - Added -p switch to 'doom sync' to make it run 'doom purge' afterwards - Replace doom-modules function with doom-modules-list - The `with-plist!` macro was removed, since `cl-destructuring-bind` already serves that purpose well enough. - core/autoload/packages.el was moved into core-packages.el - bin/doom will no longer die if DOOMDIR or DOOMLOCALDIR don't have a trailing slash - Introduces doom-debug-variables; a list of variables to toggle on doom/toggle-debug-mode. - The sandbox has been updated to reflect the above changes, also: 1. Child instances will no longer inherit the process environment of the host instance, 2. It will no longer produce an auto-save-list directory in ~/.emacs.d
2020-05-15 03:00:23 +08:00
with success = 0
with esc = (if doom-debug-p "" "\033[1A")
for path
in (append (doom-glob doom-emacs-dir "*.elc")
(doom-files-in doom-private-dir :match "\\.elc$" :depth 1)
(doom-files-in doom-core-dir :match "\\.elc$")
(doom-files-in doom-modules-dirs :match "\\.elc$" :depth 4))
if (file-exists-p path)
do (delete-file path)
Backport bits of CLI rewrite The rewrite for Doom's CLI is taking a while, so I've backported a few important changes in order to ease the transition and fix a couple bugs sooner. Fixes #2802, #2737, #2386 The big highlights are: - Fix #2802: We now update recipe repos *before* updating/installing any new packages. No more "Could not find package X in recipe repositories". - Fix #2737: An edge case where straight couldn't reach a pinned commit (particularly with agda). - Doom is now smarter about what option it recommends when straight prompts you to make a choice. - Introduces a new init path for Doom. The old way: - Launch in "minimal" CLI mode in non-interactive sessions - Launch a "full" interactive mode otherwise. The new way - Launch in "minimal" CLI mode *only* for bin/doom - Launch is a simple mode for non-interactive sessions that still need access to your interactive config (like async org export/babel). - Launch a "full" interactive mode otherwise. This should fix compatibility issues with plugins that use the async.el library or spawn child Emacs processes to fake parallelization (like org's async export and babel functionality). - Your private init.el is now loaded more reliably when running any bin/doom command. This gives you an opportunity to configure its settings. - Added doom-first-{input,buffer,file}-hook hooks, which we use to queue deferred activation of a number of packages. Users can remove these modes from these hooks; altogether preventing them from loading, rather than waiting for them to load to then disable them, e.g. (after! smartparens (smartparens-global-mode -1)) -> (remove-hook 'doom-first-buffer #'smartparens-global-mode) Hooks added to doom-first-*-hook variables will be removed once they run. This should also indirectly fix #2386, by preventing interactive modes from running in non-interactive session. - Added `doom/bump-*` commands to make bumping modules and packages easier, and `doom/bumpify-*` commands for converting package! statements into user/repo@sha1hash format for bump commits. - straight.el is now commit-pinned, like all other packages. We also more reliably install straight.el by cloning it ourselves, rather than relying on its bootstrap.el. This should prevent infinite "straight has diverged from master" prompts whenever we change branches (though, you might have to put up with it one more after this update -- see #2937 for workaround). All the other minor changes: - Moved core/autoload/cli.el to core/autoload/process.el - The package manager will log attempts to check out pinned commits - If package state is incomplete while rebuilding packages, emit a simpler error message instead of an obscure one! - Added -u switch to 'doom sync' to make it run 'doom update' afterwards - Added -p switch to 'doom sync' to make it run 'doom purge' afterwards - Replace doom-modules function with doom-modules-list - The `with-plist!` macro was removed, since `cl-destructuring-bind` already serves that purpose well enough. - core/autoload/packages.el was moved into core-packages.el - bin/doom will no longer die if DOOMDIR or DOOMLOCALDIR don't have a trailing slash - Introduces doom-debug-variables; a list of variables to toggle on doom/toggle-debug-mode. - The sandbox has been updated to reflect the above changes, also: 1. Child instances will no longer inherit the process environment of the host instance, 2. It will no longer produce an auto-save-list directory in ~/.emacs.d
2020-05-15 03:00:23 +08:00
and do (print! (success "\033[KDeleted %s%s") (relpath path) esc)
and do (cl-incf success)
finally do
Backport bits of CLI rewrite The rewrite for Doom's CLI is taking a while, so I've backported a few important changes in order to ease the transition and fix a couple bugs sooner. Fixes #2802, #2737, #2386 The big highlights are: - Fix #2802: We now update recipe repos *before* updating/installing any new packages. No more "Could not find package X in recipe repositories". - Fix #2737: An edge case where straight couldn't reach a pinned commit (particularly with agda). - Doom is now smarter about what option it recommends when straight prompts you to make a choice. - Introduces a new init path for Doom. The old way: - Launch in "minimal" CLI mode in non-interactive sessions - Launch a "full" interactive mode otherwise. The new way - Launch in "minimal" CLI mode *only* for bin/doom - Launch is a simple mode for non-interactive sessions that still need access to your interactive config (like async org export/babel). - Launch a "full" interactive mode otherwise. This should fix compatibility issues with plugins that use the async.el library or spawn child Emacs processes to fake parallelization (like org's async export and babel functionality). - Your private init.el is now loaded more reliably when running any bin/doom command. This gives you an opportunity to configure its settings. - Added doom-first-{input,buffer,file}-hook hooks, which we use to queue deferred activation of a number of packages. Users can remove these modes from these hooks; altogether preventing them from loading, rather than waiting for them to load to then disable them, e.g. (after! smartparens (smartparens-global-mode -1)) -> (remove-hook 'doom-first-buffer #'smartparens-global-mode) Hooks added to doom-first-*-hook variables will be removed once they run. This should also indirectly fix #2386, by preventing interactive modes from running in non-interactive session. - Added `doom/bump-*` commands to make bumping modules and packages easier, and `doom/bumpify-*` commands for converting package! statements into user/repo@sha1hash format for bump commits. - straight.el is now commit-pinned, like all other packages. We also more reliably install straight.el by cloning it ourselves, rather than relying on its bootstrap.el. This should prevent infinite "straight has diverged from master" prompts whenever we change branches (though, you might have to put up with it one more after this update -- see #2937 for workaround). All the other minor changes: - Moved core/autoload/cli.el to core/autoload/process.el - The package manager will log attempts to check out pinned commits - If package state is incomplete while rebuilding packages, emit a simpler error message instead of an obscure one! - Added -u switch to 'doom sync' to make it run 'doom update' afterwards - Added -p switch to 'doom sync' to make it run 'doom purge' afterwards - Replace doom-modules function with doom-modules-list - The `with-plist!` macro was removed, since `cl-destructuring-bind` already serves that purpose well enough. - core/autoload/packages.el was moved into core-packages.el - bin/doom will no longer die if DOOMDIR or DOOMLOCALDIR don't have a trailing slash - Introduces doom-debug-variables; a list of variables to toggle on doom/toggle-debug-mode. - The sandbox has been updated to reflect the above changes, also: 1. Child instances will no longer inherit the process environment of the host instance, 2. It will no longer produce an auto-save-list directory in ~/.emacs.d
2020-05-15 03:00:23 +08:00
(print! (if (> success 0)
(success "\033[K%d elc files deleted" success)
(info "\033[KNo elc files to clean"))))
t))