Don't consider used themes as orphans if they don't belong to a layer
Now it is not required to use the themes-megapack layer or define a private layer to use a theme that is not in the spacemacs layer.
This commit is contained in:
parent
1f16da0924
commit
57f802619b
|
@ -824,13 +824,21 @@ deleted safely."
|
|||
(t (let ((p (cadr (assq pkg package-alist))))
|
||||
(when p (package-delete p))))))
|
||||
|
||||
(defun configuration-layer//filter-used-themes (orphans)
|
||||
"Filter out used theme packages from ORPHANS candidates.
|
||||
Returns the filtered list."
|
||||
(delq nil (mapcar (lambda (x)
|
||||
(and (not (memq x spacemacs-used-theme-packages))
|
||||
x)) orphans)))
|
||||
|
||||
(defun configuration-layer/delete-orphan-packages ()
|
||||
"Delete all the orphan packages."
|
||||
(interactive)
|
||||
(let* ((dependencies (configuration-layer//get-packages-dependencies))
|
||||
(implicit-packages (configuration-layer//get-implicit-packages))
|
||||
(orphans (configuration-layer//get-orphan-packages implicit-packages
|
||||
dependencies))
|
||||
(orphans (configuration-layer//filter-used-themes
|
||||
(configuration-layer//get-orphan-packages implicit-packages
|
||||
dependencies)))
|
||||
(orphans-count (length orphans)))
|
||||
;; (message "dependencies: %s" dependencies)
|
||||
;; (message "implicit: %s" implicit-packages)
|
||||
|
|
|
@ -83,6 +83,10 @@ initialization."
|
|||
;; default theme
|
||||
(let ((default-theme (car dotspacemacs-themes)))
|
||||
(spacemacs/load-theme default-theme)
|
||||
;; used to prevent automatic deletion of used packages
|
||||
(setq spacemacs-used-theme-packages
|
||||
(delq nil (mapcar 'spacemacs//get-theme-package
|
||||
dotspacemacs-themes)))
|
||||
(setq-default spacemacs--cur-theme default-theme)
|
||||
(setq-default spacemacs--cycle-themes (cdr dotspacemacs-themes)))
|
||||
;; removes the GUI elements
|
||||
|
|
|
@ -10,6 +10,9 @@
|
|||
;;
|
||||
;;; License: GPLv3
|
||||
|
||||
(defconst emacs-built-in-themes (custom-available-themes)
|
||||
"List of emacs built-in themes")
|
||||
|
||||
(defconst spacemacs-theme-name-to-package
|
||||
'(
|
||||
(alect-black-alt . alect-themes)
|
||||
|
@ -37,6 +40,8 @@
|
|||
(sanityinc-tomorrow-day . color-theme-sanityinc-tomorrow)
|
||||
(sanityinc-tomorrow-eighties . color-theme-sanityinc-tomorrow)
|
||||
(sanityinc-tomorrow-night . color-theme-sanityinc-tomorrow)
|
||||
(solarized-light . solarized-theme)
|
||||
(solarized-dark . solarized-theme)
|
||||
(colorsarenice-dark . colorsarenice-theme)
|
||||
(colorsarenice-light . colorsarenice-theme)
|
||||
(hemisu-dark . hemisu-theme)
|
||||
|
@ -64,15 +69,29 @@
|
|||
"alist matching a theme name with its package name, required when
|
||||
package name does not match theme name + `-theme' suffix.")
|
||||
|
||||
(defvar spacemacs-used-theme-packages nil
|
||||
"List of packages of used themes.")
|
||||
|
||||
(defun spacemacs//get-theme-package (theme)
|
||||
"Returns the package theme for the given THEME name."
|
||||
(cond
|
||||
;; built-in
|
||||
((memq theme emacs-built-in-themes) nil)
|
||||
;; from explicit alist
|
||||
((assq theme spacemacs-theme-name-to-package)
|
||||
(cdr (assq theme spacemacs-theme-name-to-package)))
|
||||
;; fallback to <name>-theme
|
||||
(t (intern (format "%S-theme" theme)))))
|
||||
|
||||
(defun spacemacs/load-theme (theme)
|
||||
"Load THEME."
|
||||
;; Unless Emacs stock themes
|
||||
;; Required dependencies for some themes
|
||||
(when (or (eq 'zonokai-blue theme)
|
||||
(eq 'zonokai-red theme)
|
||||
(eq 'solarized-light theme)
|
||||
(eq 'solarized-dark theme))
|
||||
;; required dependencies
|
||||
(spacemacs/load-or-install-package 'dash))
|
||||
;; Unless Emacs stock themes
|
||||
(unless (memq theme (custom-available-themes))
|
||||
(cond
|
||||
;; solarized theme, official spacemacs theme
|
||||
|
@ -85,7 +104,7 @@ package name does not match theme name + `-theme' suffix.")
|
|||
(deftheme solarized-light "The light variant of the Solarized colour theme"))
|
||||
;; themes with explicitly declared package names
|
||||
((assq theme spacemacs-theme-name-to-package)
|
||||
(let* ((pkg (cdr (assq theme spacemacs-theme-name-to-package)))
|
||||
(let* ((pkg (spacemacs//get-theme-package theme))
|
||||
(pkg-dir (spacemacs/load-or-install-package pkg)))
|
||||
(when (or (eq 'moe-light theme)
|
||||
(eq 'moe-dark theme))
|
||||
|
@ -96,8 +115,8 @@ package name does not match theme name + `-theme' suffix.")
|
|||
;; other themes
|
||||
;; we assume that the package name is suffixed with `-theme'
|
||||
;; if not we will handle the special themes as we get issues in the tracker.
|
||||
(let ((pkg (format "%s-theme" (symbol-name theme))))
|
||||
(spacemacs/load-or-install-package (intern pkg))))))
|
||||
(let ((pkg (spacemacs//get-theme-package theme)))
|
||||
(spacemacs/load-or-install-package pkg)))))
|
||||
(load-theme theme t))
|
||||
|
||||
(defun spacemacs/cycle-spacemacs-theme ()
|
||||
|
|
|
@ -707,7 +707,11 @@ the variable `dotspacemacs-themes`. For instance, to specify `leuven` and
|
|||
<kbd>SPC T n</kbd> | switch to next theme listed in `dotspacemacs-themes`.
|
||||
<kbd>SPC T h</kbd> | select a theme using a `helm` buffer.
|
||||
|
||||
**Note:** Due to the inner working of themes in Emacs, switching theme during
|
||||
**Note:**
|
||||
- You don't need to explicitly list in a layer the theme packages you are
|
||||
defining in `dotspacemacs-themes`, Spacemacs is smart enough to remove those
|
||||
packages from the list of orphans.
|
||||
- Due to the inner working of themes in Emacs, switching theme during
|
||||
the same session may have some weird side effects. Although these side effects
|
||||
should be pretty rare.
|
||||
|
||||
|
|
Loading…
Reference in New Issue