refactor: move file-name-handler-alist hack to early-init
In the future, early-init.el (among other parts of Doom) will be
byte-compiled, plus I'd rather keep these optimizations in one place.
Ref: 1d8c61698b
This commit is contained in:
parent
71469d8056
commit
1dac4ac37b
2 changed files with 16 additions and 18 deletions
|
@ -30,13 +30,23 @@
|
||||||
|
|
||||||
(unless (or (daemonp)
|
(unless (or (daemonp)
|
||||||
init-file-debug)
|
init-file-debug)
|
||||||
|
;; PERF: `file-name-handler-alist' is consulted on each `require', `load' and
|
||||||
|
;; various path/io functions (like `expand-file-name'). You get a minor, but
|
||||||
|
;; noteable, boost by unsetting this.
|
||||||
(let ((old-file-name-handler-alist file-name-handler-alist))
|
(let ((old-file-name-handler-alist file-name-handler-alist))
|
||||||
;; `file-name-handler-alist' is consulted on each `require', `load' and
|
(setq file-name-handler-alist
|
||||||
;; various path/io functions. You get a minor speed up by unsetting this.
|
;; HACK: If the bundled elisp for this Emacs install isn't
|
||||||
;; Some warning, however: this could cause problems on builds of Emacs where
|
;; byte-compiled (but is compressed), then leave the gzip file
|
||||||
;; its site lisp files aren't byte-compiled and we're forced to load the
|
;; handler there so Emacs won't forget how to read read them.
|
||||||
;; *.el.gz files (e.g. on Alpine).
|
;;
|
||||||
(setq-default file-name-handler-alist nil)
|
;; calc-loaddefs.el is our heuristic for this because it is built-in
|
||||||
|
;; in all supported versions of Emacs, and calc.el explicitly load
|
||||||
|
;; it uncompiled. This ensure the only other, psosible fallback
|
||||||
|
;; would be calc-loaddefs.el.gz.
|
||||||
|
(if (eval-when-compile
|
||||||
|
(locate-file-internal "calc-loaddefs.el" load-path nil))
|
||||||
|
nil
|
||||||
|
(list (rassq 'jka-compr-handler file-name-handler-alist))))
|
||||||
;; ...but restore `file-name-handler-alist' later, because it is needed for
|
;; ...but restore `file-name-handler-alist' later, because it is needed for
|
||||||
;; handling encrypted or compressed files, among other things.
|
;; handling encrypted or compressed files, among other things.
|
||||||
(defun doom-reset-file-handler-alist-h ()
|
(defun doom-reset-file-handler-alist-h ()
|
||||||
|
|
|
@ -44,18 +44,6 @@ hoist buggy forms into autoloads.")
|
||||||
(signal 'doom-error
|
(signal 'doom-error
|
||||||
(list "The installed version of Doom has changed since last 'doom sync' ran"
|
(list "The installed version of Doom has changed since last 'doom sync' ran"
|
||||||
"Run 'doom sync' to bring Doom up to speed"))))
|
"Run 'doom sync' to bring Doom up to speed"))))
|
||||||
;; HACK If the bundled elisp for this Emacs install isn't
|
|
||||||
;; byte-compiled, disengage the `file-name-handler-alist'
|
|
||||||
;; optimization early to prevent encoding errors when Emacs tries to
|
|
||||||
;; read gzipped elisp.
|
|
||||||
;;
|
|
||||||
;; calc-loaddefs.el is a good heuristic for this because calc.el
|
|
||||||
;; explicitly tries to load the un-compiled calc-loaddefs.el. If it
|
|
||||||
;; doesn't exist, it'll go for calc-loaddefs.el.gz instead.
|
|
||||||
(unless (locate-file "calc-loaddefs.el" (get 'load-path 'initial-value) nil)
|
|
||||||
`((when (fboundp 'doom-reset-file-handler-alist-h)
|
|
||||||
(doom-reset-file-handler-alist-h)
|
|
||||||
(remove-hook 'emacs-startup-hook #'doom-reset-file-handler-alist-h))))
|
|
||||||
(cl-loop for var in doom-autoloads-cached-vars
|
(cl-loop for var in doom-autoloads-cached-vars
|
||||||
when (boundp var)
|
when (boundp var)
|
||||||
collect `(set ',var ',(symbol-value var)))
|
collect `(set ',var ',(symbol-value var)))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue