From 96fd57bb90b44caed0f31c8222dce2b39303021f Mon Sep 17 00:00:00 2001 From: Daniel Borchmann Date: Fri, 20 Dec 2019 17:05:20 +0100 Subject: [PATCH] Load customizations directy during initialization time Loading customizations in `db/run-init' may cause accidental overwrites of custom settings when loading variables changes and saves values of other customizable variables. For example, loading `custom-enabled-themes' may update `custom-safe-themes', and if this loading happens after initialization time, this update is directly written to custom.el via a call to `customize-push-and-save', overwriting all remaining, i.e. not loaded, custom settings. Loading custom settings during initialzation time prevents this behavior. Note that this change causes some packages to load during initialization time that previously had been loaded only afterwards. --- README.org | 16 ++++++++-------- init.el | 11 ++++++----- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/README.org b/README.org index 295e1de..31e992d 100644 --- a/README.org +++ b/README.org @@ -77,14 +77,14 @@ data (like customization) is outsourced into a separate directory named work nevertheless, even without these private files. The main =init.el= file consists mostly of variable assignments, =use-package= -declarations, and initializing the =package= subsystem. The main lifting is -done by the =db/run-init= function, which is attached to the =after-init-hook= -in =init.el=. This way, all necessary local hooks and autoloads are set up by -=init.el=, and the =db/run-init= functions only activates a (minimal?) -configurations needed for every session, including modes, keybindings, hydras, -and global hooks. It also imports some environment variables and starts the -server when running under windows. Any additional packages are only loaded when -required. +declarations, initializing the =package= subsystem, and loading customizations. +The main lifting is done by the =db/run-init= function, which is attached to the +=after-init-hook= in =init.el=. This way, all necessary local hooks and +autoloads are set up by =init.el=, and the =db/run-init= functions only +activates a (minimal?) configurations needed for every session, including +modes, keybindings, hydras, and global hooks. It also imports some environment +variables and starts the server when running under windows. Any additional +packages are only loaded when required. Lastly, ~db/run-init~ loads all files contained in ~db/after-init-load-files~, in that order. diff --git a/init.el b/init.el index 2c78663..6b8629a 100644 --- a/init.el +++ b/init.el @@ -66,11 +66,6 @@ (message "Running main initialization ...") - ;; Load customizations - - (when (file-exists-p custom-file) - (load-file custom-file)) - ;; Activate modes (builtin) (show-paren-mode 1) @@ -2818,4 +2813,10 @@ With given ARG, display files in `db/important-document-path’." :diminish yas-minor-mode :config (yas-reload-all)) + +;; * Load customizations + +(when (file-exists-p custom-file) + (load-file custom-file)) + ;;; init.el ends here