custom setting: don't write to dotfile before loading all of them
Fixes a bug where saving a custom variable (e.g. package-selected-packages) before reading the custom settings from dotspacemacs/emacs-custom-settings could overwrite the stored settings.
This commit is contained in:
parent
f6a42ef790
commit
5eff620e83
|
@ -14,13 +14,13 @@
|
||||||
".custom-settings"))
|
".custom-settings"))
|
||||||
|
|
||||||
(defun spacemacs/initialize-custom-file ()
|
(defun spacemacs/initialize-custom-file ()
|
||||||
"Initialize the custom file."
|
"Initialize the custom file.
|
||||||
|
Does not initialize writing the custom file into the dotfile. To
|
||||||
|
complete that part see `spacemacs/initialize-custom-file-sync'."
|
||||||
;; setup auto-rewrite of custom settings only if custom-file
|
;; setup auto-rewrite of custom settings only if custom-file
|
||||||
;; has not been set by the user
|
;; has not been set by the user
|
||||||
(when (null custom-file)
|
(when (null custom-file)
|
||||||
(setq custom-file spacemacs--custom-file)
|
(setq custom-file spacemacs--custom-file))
|
||||||
(advice-add 'custom-save-all :after
|
|
||||||
#'spacemacs/write-custom-settings-to-dotfile))
|
|
||||||
;; initialize the cache file contents
|
;; initialize the cache file contents
|
||||||
(unless (or (not (string-equal custom-file spacemacs--custom-file))
|
(unless (or (not (string-equal custom-file spacemacs--custom-file))
|
||||||
(file-exists-p spacemacs--custom-file))
|
(file-exists-p spacemacs--custom-file))
|
||||||
|
@ -32,6 +32,12 @@
|
||||||
;; function `dotspacemacs/emacs-custom-settings'.
|
;; function `dotspacemacs/emacs-custom-settings'.
|
||||||
;; Do not alter this file, use Emacs customize interface instead.\n\n")))))
|
;; Do not alter this file, use Emacs customize interface instead.\n\n")))))
|
||||||
|
|
||||||
|
(defun spacemacs/initialize-custom-file-sync ()
|
||||||
|
"Initialize syncing of the custom file to the dotfile."
|
||||||
|
(when (string-equal custom-file spacemacs--custom-file)
|
||||||
|
(advice-add 'custom-save-all :after
|
||||||
|
#'spacemacs/write-custom-settings-to-dotfile)))
|
||||||
|
|
||||||
(defun spacemacs//delete-emacs-custom-settings ()
|
(defun spacemacs//delete-emacs-custom-settings ()
|
||||||
"Delete function `dotspacemacs/emacs-custom-settings' from dotfile.
|
"Delete function `dotspacemacs/emacs-custom-settings' from dotfile.
|
||||||
|
|
||||||
|
|
|
@ -211,6 +211,9 @@ Note: the hooked function is not executed when in dumped mode."
|
||||||
"Calling dotfile user config...")
|
"Calling dotfile user config...")
|
||||||
(dotspacemacs|call-func dotspacemacs/emacs-custom-settings
|
(dotspacemacs|call-func dotspacemacs/emacs-custom-settings
|
||||||
"Calling dotfile Emacs custom settings...")
|
"Calling dotfile Emacs custom settings...")
|
||||||
|
;; don't write custom settings into the dotfile before loading them,
|
||||||
|
;; otherwise https://github.com/syl20bnr/spacemacs/issues/10504 happens
|
||||||
|
(spacemacs/initialize-custom-file-sync)
|
||||||
(run-hooks 'spacemacs-post-user-config-hook)
|
(run-hooks 'spacemacs-post-user-config-hook)
|
||||||
(setq spacemacs-post-user-config-hook-run t)
|
(setq spacemacs-post-user-config-hook-run t)
|
||||||
(when (fboundp dotspacemacs-scratch-mode)
|
(when (fboundp dotspacemacs-scratch-mode)
|
||||||
|
|
Loading…
Reference in a new issue