fix: ensure top-level file-name-handler-alist is affected
Ensures that lexical contexts are never taken into account, in the case where Doom's core is loaded in an isolated environment (e.g. the sandbox). Also improves my startup time by 10%? I'll take it.
This commit is contained in:
parent
f1e77e6692
commit
a5ffbd8550
1 changed files with 19 additions and 17 deletions
36
lisp/doom.el
36
lisp/doom.el
|
@ -331,19 +331,20 @@ users).")
|
||||||
;; `file-remote-p'). You get a noteable boost to startup time by unsetting
|
;; `file-remote-p'). You get a noteable boost to startup time by unsetting
|
||||||
;; or simplifying its value.
|
;; or simplifying its value.
|
||||||
(let ((old-value (default-toplevel-value 'file-name-handler-alist)))
|
(let ((old-value (default-toplevel-value 'file-name-handler-alist)))
|
||||||
(setq file-name-handler-alist
|
(set-default-toplevel-value
|
||||||
;; HACK: If the bundled elisp for this Emacs install isn't
|
'file-name-handler-alist
|
||||||
;; byte-compiled (but is compressed), then leave the gzip file
|
;; HACK: If the bundled elisp for this Emacs install isn't byte-compiled
|
||||||
;; handler there so Emacs won't forget how to read read them.
|
;; (but is compressed), then leave the gzip file handler there so Emacs
|
||||||
;;
|
;; won't forget how to read read them.
|
||||||
;; calc-loaddefs.el is our heuristic for this because it is built-in
|
;;
|
||||||
;; to all supported versions of Emacs, and calc.el explicitly loads
|
;; calc-loaddefs.el is our heuristic for this because it is built-in to
|
||||||
;; it uncompiled. This ensures that the only other, possible
|
;; all supported versions of Emacs, and calc.el explicitly loads it
|
||||||
;; fallback would be calc-loaddefs.el.gz.
|
;; uncompiled. This ensures that the only other, possible fallback would
|
||||||
(if (eval-when-compile
|
;; be calc-loaddefs.el.gz.
|
||||||
(locate-file-internal "calc-loaddefs.el" load-path))
|
(if (eval-when-compile
|
||||||
nil
|
(locate-file-internal "calc-loaddefs.el" load-path))
|
||||||
(list (rassq 'jka-compr-handler old-value))))
|
nil
|
||||||
|
(list (rassq 'jka-compr-handler old-value))))
|
||||||
;; Make sure the new value survives any current let-binding.
|
;; Make sure the new value survives any current let-binding.
|
||||||
(set-default-toplevel-value 'file-name-handler-alist file-name-handler-alist)
|
(set-default-toplevel-value 'file-name-handler-alist file-name-handler-alist)
|
||||||
;; Remember it so it can be reset where needed.
|
;; Remember it so it can be reset where needed.
|
||||||
|
@ -352,10 +353,11 @@ users).")
|
||||||
;; needed for handling encrypted or compressed files, among other things.
|
;; needed for handling encrypted or compressed files, among other things.
|
||||||
(add-hook! 'emacs-startup-hook :depth 101
|
(add-hook! 'emacs-startup-hook :depth 101
|
||||||
(defun doom--reset-file-handler-alist-h ()
|
(defun doom--reset-file-handler-alist-h ()
|
||||||
(setq file-name-handler-alist
|
(set-default-toplevel-value
|
||||||
;; Merge instead of overwrite because there may have been changes to
|
'file-name-handler-alist
|
||||||
;; `file-name-handler-alist' since startup we want to preserve.
|
;; Merge instead of overwrite because there may have been changes to
|
||||||
(delete-dups (append file-name-handler-alist old-value))))))
|
;; `file-name-handler-alist' since startup we want to preserve.
|
||||||
|
(delete-dups (append file-name-handler-alist old-value))))))
|
||||||
|
|
||||||
(unless noninteractive
|
(unless noninteractive
|
||||||
;; PERF: Resizing the Emacs frame (to accommodate fonts that are smaller or
|
;; PERF: Resizing the Emacs frame (to accommodate fonts that are smaller or
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue