Add NOERROR arg to doom-initialize

This commit is contained in:
Henrik Lissner 2019-12-05 14:52:30 -05:00
parent 172260118e
commit 4300957aea
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
2 changed files with 17 additions and 18 deletions

View file

@ -197,7 +197,7 @@ BODY will be run when this dispatcher is called."
collect (list optsym `(cdr (assq ',optsym --alist--)))) collect (list optsym `(cdr (assq ',optsym --alist--))))
,@(unless (plist-get plist :bare) ,@(unless (plist-get plist :bare)
'((unless doom-init-p '((unless doom-init-p
(doom-initialize 'force) (doom-initialize 'force 'noerror)
(doom-initialize-modules)))) (doom-initialize-modules))))
,@body))) ,@body)))
doom--cli-commands) doom--cli-commands)

View file

@ -402,18 +402,21 @@ If RETURN-P, return the message as a string instead of displaying it."
(setq doom-init-time (setq doom-init-time
(float-time (time-subtract (current-time) before-init-time)))))) (float-time (time-subtract (current-time) before-init-time))))))
(defun doom-load-autoloads-file (file) (defun doom-load-autoloads-file (file &optional noerror)
"Tries to load FILE (an autoloads file). Return t on success, throws an error "Tries to load FILE (an autoloads file).
in interactive sessions, nil otherwise (but logs a warning)." Return t on success, nil otherwise (but logs a warning)."
(condition-case e (condition-case e
(let (command-switch-alist) (let (command-switch-alist)
(load (substring file 0 -3) 'noerror 'nomessage)) (load (substring file 0 -3) noerror 'nomessage))
((debug error) ((debug error)
(message "Autoload file error: %s -> %s" (file-name-nondirectory file) e) (message "Autoload file error: %s -> %s" (file-name-nondirectory file) e)
nil))) nil)))
(defun doom-load-envvars-file (file &optional noerror) (defun doom-load-envvars-file (file &optional noerror)
"Read and set envvars from FILE." "Read and set envvars from FILE.
If NOERROR is non-nil, don't throw an error if the file doesn't exist or is
unreadable. Returns a list of VAR=VALUE strings for all environment variables
set."
(if (not (file-readable-p file)) (if (not (file-readable-p file))
(unless noerror (unless noerror
(signal 'file-error (list "Couldn't read envvar file" file))) (signal 'file-error (list "Couldn't read envvar file" file)))
@ -446,16 +449,13 @@ in interactive sessions, nil otherwise (but logs a warning)."
shell-file-name)) shell-file-name))
envvars)))) envvars))))
(defun doom-initialize (&optional force-p) (defun doom-initialize (&optional force-p noerror)
"Bootstrap Doom, if it hasn't already (or if FORCE-P is non-nil). "Bootstrap Doom, if it hasn't already (or if FORCE-P is non-nil).
The bootstrap process involves making sure 1) the essential directories exist, The bootstrap process ensures that the essential directories exist, all core
2) the core packages are installed, 3) `doom-autoload-file' and packages are installed, `doom-autoload-file' and `doom-package-autoload-file'
`doom-package-autoload-file' exist and have been loaded, and 4) Doom's core exist and are loaded, and that `core-packages' is auto-loaded when `package' or
files are loaded. `straight' are.
If the cache exists, much of this function isn't run, which substantially
reduces startup time.
The overall load order of Doom is as follows: The overall load order of Doom is as follows:
@ -494,12 +494,12 @@ to least)."
(let (;; `doom-autoload-file' tells Emacs where to load all its functions (let (;; `doom-autoload-file' tells Emacs where to load all its functions
;; from. This includes everything in core/autoload/*.el and autoload ;; from. This includes everything in core/autoload/*.el and autoload
;; files in enabled modules. ;; files in enabled modules.
(core-autoloads-p (doom-load-autoloads-file doom-autoload-file)) (core-autoloads-p (doom-load-autoloads-file doom-autoload-file noerror))
;; Loads `doom-package-autoload-file', which loads a concatenated ;; Loads `doom-package-autoload-file', which loads a concatenated
;; package autoloads file which caches `load-path', `auto-mode-alist', ;; package autoloads file which caches `load-path', `auto-mode-alist',
;; `Info-directory-list', and `doom-disabled-packages'. A big ;; `Info-directory-list', and `doom-disabled-packages'. A big
;; reduction in startup time. ;; reduction in startup time.
(pkg-autoloads-p (doom-load-autoloads-file doom-package-autoload-file))) (pkg-autoloads-p (doom-load-autoloads-file doom-package-autoload-file noerror)))
(if (and core-autoloads-p pkg-autoloads-p (not force-p)) (if (and core-autoloads-p pkg-autoloads-p (not force-p))
;; In case we want to use package.el or straight via M-x ;; In case we want to use package.el or straight via M-x
@ -523,8 +523,7 @@ to least)."
(doom-initialize-packages force-p)) (doom-initialize-packages force-p))
(unless (or (and core-autoloads-p pkg-autoloads-p) (unless (or (and core-autoloads-p pkg-autoloads-p)
force-p noerror)
(not doom-interactive-mode))
(unless core-autoloads-p (unless core-autoloads-p
(warn "Your Doom core autoloads file is missing")) (warn "Your Doom core autoloads file is missing"))
(unless pkg-autoloads-p (unless pkg-autoloads-p