syl20bnr / spacemacs

A community-driven Emacs distribution - The best editor is neither Emacs nor Vim, it's Emacs *and* Vim!
http://spacemacs.org
GNU General Public License v3.0
23.71k stars 4.9k forks source link

Fix failed on the default theme and not depending on package-activate #16650

Closed sunlin7 closed 1 week ago

sunlin7 commented 1 week ago

Hi,

Spacemacs has issues on theme,

  1. Error on default theme: a) write the dotspacemacs-themes to (default), then start Spacemacs with daemon mode: emacs --daemon b) start a graphic emacsclient: emacsclient -c . Then error happens: *ERROR*: Unable to find theme file for ‘default’. This patch will try load theme but not try enable it first, if the theme is exists then enable the theme; otherwise set the theme to spacemacs--delayed-user-theme to postpone the operation.
  2. For a <non-exists> theme in dotspacemacs-themes, then Spacemacs will switch theme from default -> spacemacs-dark(fallback-theme) -> default -> spacemacs-dark(fallbak-theme) during startup: a) write the dotspacemacs-themes to (non-exists), then restart the Spacemacs. b) the Spacemacs will flash during the startup. It caused by the spacemacs/load-default-theme will try load the non-exists theme then fallback to the spacemacs-dark, and in emacs-startup-hook it will load the spacemacs--delayed-user-theme again, it still is not exists, then fallback to spacemacs-dark again. This patch won't try the fallback-theme for first attempt, only fallback at the last one.
  3. Spacemacs theme function relates to the package-activate function, which requests the package-initialize will load all the *-pkg.el and *-autoloads.el for packages; cause a heavy loading; This change will disconnect the theme from package-activate, will let the package-quickstartup to work, refer: https://github.com/syl20bnr/spacemacs/pull/16651 .