Merge branch 'main' of https://github.com/jamescherti/minimal-emacs.d
This commit is contained in:
@@ -24,10 +24,14 @@
|
||||
|
||||
;;; Internal variables
|
||||
|
||||
(defvar minimal-emacs--backup-gc-cons-threshold gc-cons-threshold
|
||||
"Backup of the original value of `gc-cons-threshold' before startup.")
|
||||
;; Backup of `gc-cons-threshold' and `gc-cons-percentage' before startup.
|
||||
(defvar minimal-emacs--backup-gc-cons-threshold gc-cons-threshold)
|
||||
(defvar minimal-emacs--backup-gc-cons-percentage gc-cons-percentage)
|
||||
|
||||
;; Temporarily raise the garbage collection threshold to its maximum value.
|
||||
;; It will be restored later to controlled values.
|
||||
(setq gc-cons-threshold most-positive-fixnum)
|
||||
(setq gc-cons-percentage 1.0)
|
||||
|
||||
;;; Variables
|
||||
|
||||
@@ -55,6 +59,10 @@ stored in `minimal-emacs-gc-cons-threshold'.")
|
||||
"Value to which `gc-cons-threshold' is set after Emacs startup.
|
||||
Ignored if `minimal-emacs-optimize-startup-gc' is nil.")
|
||||
|
||||
(defvar minimal-emacs-gc-cons-percentage gc-cons-percentage
|
||||
"Value to which `gc-cons-percentage' is set after Emacs startup.
|
||||
Ignored if `minimal-emacs-optimize-startup-gc' is nil.")
|
||||
|
||||
(defvar minimal-emacs-gc-cons-threshold-restore-delay nil
|
||||
"Number of seconds to wait before restoring `gc-cons-threshold'.")
|
||||
|
||||
@@ -138,11 +146,11 @@ pre-early-init.el, and post-early-init.el.")
|
||||
(let ((init-file (expand-file-name filename
|
||||
minimal-emacs-user-directory)))
|
||||
(if (not minimal-emacs-load-compiled-init-files)
|
||||
(load init-file :no-error :no-message :nosuffix)
|
||||
(load init-file :no-error (not init-file-debug) :nosuffix)
|
||||
;; Remove the file suffix (.el, .el.gz, etc.) to let the `load' function
|
||||
;; select between .el and .elc files.
|
||||
(setq init-file (minimal-emacs--remove-el-file-suffix init-file))
|
||||
(load init-file :no-error :no-message))))
|
||||
(load init-file :no-error (not init-file-debug)))))
|
||||
|
||||
(minimal-emacs-load-user-init "pre-early-init.el")
|
||||
|
||||
@@ -157,23 +165,26 @@ pre-early-init.el, and post-early-init.el.")
|
||||
|
||||
(setq garbage-collection-messages minimal-emacs-debug)
|
||||
|
||||
(defun minimal-emacs--restore-gc-cons-threshold ()
|
||||
"Restore `gc-cons-threshold' to `minimal-emacs-gc-cons-threshold'."
|
||||
(defun minimal-emacs--restore-gc-values ()
|
||||
"Restore garbage collection values to minimal-emacs.d values."
|
||||
(setq gc-cons-threshold minimal-emacs-gc-cons-threshold)
|
||||
(setq gc-cons-percentage minimal-emacs-gc-cons-percentage))
|
||||
|
||||
(defun minimal-emacs--restore-gc ()
|
||||
"Restore garbage collection settings."
|
||||
(if (bound-and-true-p minimal-emacs-gc-cons-threshold-restore-delay)
|
||||
;; Defer garbage collection during initialization to avoid 2 collections.
|
||||
(run-at-time
|
||||
minimal-emacs-gc-cons-threshold-restore-delay nil
|
||||
(lambda () (setq gc-cons-threshold minimal-emacs-gc-cons-threshold)))
|
||||
(setq gc-cons-threshold minimal-emacs-gc-cons-threshold)))
|
||||
(run-with-timer minimal-emacs-gc-cons-threshold-restore-delay nil
|
||||
#'minimal-emacs--restore-gc-values)
|
||||
(minimal-emacs--restore-gc-values)))
|
||||
|
||||
(if minimal-emacs-optimize-startup-gc
|
||||
;; `gc-cons-threshold' is managed by minimal-emacs.d
|
||||
(add-hook 'emacs-startup-hook #'minimal-emacs--restore-gc-cons-threshold 105)
|
||||
(add-hook 'emacs-startup-hook #'minimal-emacs--restore-gc 105)
|
||||
;; gc-cons-threshold is not managed by minimal-emacs.d.
|
||||
;; If it is equal to `most-positive-fixnum', this indicates that the user has
|
||||
;; not overridden the value in their `pre-early-init.el' configuration.
|
||||
(when (= gc-cons-threshold most-positive-fixnum)
|
||||
(setq gc-cons-threshold minimal-emacs--backup-gc-cons-threshold)))
|
||||
(setq gc-cons-threshold minimal-emacs--backup-gc-cons-threshold)
|
||||
(setq gc-cons-percentage minimal-emacs--backup-gc-cons-percentage)))
|
||||
|
||||
;;; Native compilation and Byte compilation
|
||||
|
||||
@@ -182,9 +193,7 @@ pre-early-init.el, and post-early-init.el.")
|
||||
(native-comp-available-p))
|
||||
(when minimal-emacs-setup-native-compilation
|
||||
;; Activate `native-compile'
|
||||
(setq native-comp-deferred-compilation t
|
||||
native-comp-jit-compilation t
|
||||
package-native-compile t))
|
||||
(setq package-native-compile t))
|
||||
;; Deactivate the `native-compile' feature if it is not available
|
||||
(setq features (delq 'native-compile features)))
|
||||
|
||||
@@ -468,18 +477,18 @@ this stage of initialization."
|
||||
(setq package-enable-at-startup nil) ; Let the init.el file handle this
|
||||
(setq use-package-always-ensure t)
|
||||
(setq use-package-enable-imenu-support t)
|
||||
(setq package-archives '(("melpa" . "https://melpa.org/packages/")
|
||||
("gnu" . "https://elpa.gnu.org/packages/")
|
||||
("nongnu" . "https://elpa.nongnu.org/nongnu/")))
|
||||
(setq package-archives '(("melpa" . "https://melpa.org/packages/")
|
||||
("gnu" . "https://elpa.gnu.org/packages/")
|
||||
("nongnu" . "https://elpa.nongnu.org/nongnu/")
|
||||
("melpa-stable" . "https://stable.melpa.org/packages/")))
|
||||
(setq package-archive-priorities '(("gnu" . 99)
|
||||
("nongnu" . 80)
|
||||
("melpa" . 70)))
|
||||
("melpa" . 70)
|
||||
("melpa-stable" . 50)))
|
||||
|
||||
;;; Load post-early-init.el
|
||||
(minimal-emacs-load-user-init "post-early-init.el")
|
||||
|
||||
(provide 'early-init)
|
||||
|
||||
;; Local variables:
|
||||
;; byte-compile-warnings: (not obsolete free-vars)
|
||||
;; End:
|
||||
|
||||
Reference in New Issue
Block a user