Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

custom setting: don't write to dotfile before loading all of them #11994

Merged
merged 1 commit into from
Feb 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions core/core-custom-settings.el
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
".custom-settings"))

(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
;; has not been set by the user
(when (null custom-file)
(setq custom-file spacemacs--custom-file)
(advice-add 'custom-save-all :after
#'spacemacs/write-custom-settings-to-dotfile))
(setq custom-file spacemacs--custom-file))
;; initialize the cache file contents
(unless (or (not (string-equal custom-file spacemacs--custom-file))
(file-exists-p spacemacs--custom-file))
Expand All @@ -32,6 +32,12 @@
;; function `dotspacemacs/emacs-custom-settings'.
;; 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 ()
"Delete function `dotspacemacs/emacs-custom-settings' from dotfile.

Expand Down
3 changes: 3 additions & 0 deletions core/core-spacemacs.el
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,9 @@ Note: the hooked function is not executed when in dumped mode."
"Calling dotfile user config...")
(dotspacemacs|call-func dotspacemacs/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)
(setq spacemacs-post-user-config-hook-run t)
(when (fboundp dotspacemacs-scratch-mode)
Expand Down