Skip to content

Commit

Permalink
[cherry-pick] core-themes-support.el: Run hooks after enable-theme no…
Browse files Browse the repository at this point in the history
…t load-theme

See syl20bnr#16717
  • Loading branch information
bcc32 committed Dec 11, 2024
1 parent 87712d9 commit b141a15
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 31 deletions.
10 changes: 2 additions & 8 deletions core/core-themes-support.el
Original file line number Diff line number Diff line change
Expand Up @@ -434,10 +434,10 @@ When BACKWARD is non-nil, or with universal-argument, cycle backwards."
(interactive)
(spacemacs/cycle-spacemacs-theme t))

(define-advice load-theme (:after (theme &rest _) spacemacs/load-theme-adv)
(define-advice enable-theme (:after (theme &rest _) spacemacs//run-post-theme-hooks)
"Perform post load processing."
(setq spacemacs--cur-theme theme)
(spacemacs/post-theme-init theme))
(run-hooks 'spacemacs-post-theme-change-hook))

(defun spacemacs/theme-loader ()
"Call appropriate theme loader based on completion framework."
Expand All @@ -449,12 +449,6 @@ When BACKWARD is non-nil, or with universal-argument, cycle backwards."
(call-interactively 'counsel-load-theme))
(t (call-interactively 'load-theme))))

(defun spacemacs/post-theme-init (theme)
"Some processing that needs to be done when the current theme
has been changed to THEME."
(interactive)
(run-hooks 'spacemacs-post-theme-change-hook))

(defun spacemacs//add-theme-packages-to-additional-packages ()
"Add all theme packages from `dotspacemacs-themes' to packages to install."
(setq dotspacemacs--additional-theme-packages nil)
Expand Down
12 changes: 12 additions & 0 deletions layers/+spacemacs/spacemacs-completion/funcs.el
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,18 @@ See https://github.com/syl20bnr/spacemacs/issues/3700"
(call-interactively 'helm-select-action)
(spacemacs//helm-navigation-ts-set-face))

(defun spacemacs//helm-update-header-line-faces ()
"Update defaults for `helm' header line whenever a new theme is loaded."
;; TODO factorize face definition with those defined in config.el
(setq helm-source-header-default-foreground
(face-attribute 'helm-source-header :foreground)
helm-source-header-default-background
(face-attribute 'helm-source-header :background)
helm-source-header-default-box
(face-attribute 'helm-source-header :box)
helm-source-header-default-height
(face-attribute 'helm-source-header :height)))


;; Ivy

Expand Down
14 changes: 1 addition & 13 deletions layers/+spacemacs/spacemacs-completion/packages.el
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,7 @@
(add-hook 'spacemacs-editing-style-hook 'spacemacs//helm-hjkl-navigation)
(add-hook 'helm-find-files-after-init-hook
'spacemacs//helm-find-files-enable-helm--in-fuzzy)
;; setup advices
(define-advice spacemacs/post-theme-init
(:after (&rest _) spacemacs/helm-header-line-adv)
"Update defaults for `helm' header line whenever a new theme is loaded"
;; TODO factorize face definition with those defined in config.el
(setq helm-source-header-default-foreground
(face-attribute 'helm-source-header :foreground)
helm-source-header-default-background
(face-attribute 'helm-source-header :background)
helm-source-header-default-box
(face-attribute 'helm-source-header :box)
helm-source-header-default-height
(face-attribute 'helm-source-header :height)))
(add-hook 'spacemacs-post-theme-change-hook #'spacemacs//helm-update-header-line-faces)
;; ensure that the correct bindings are set at startup
(spacemacs//helm-hjkl-navigation dotspacemacs-editing-style)
;; Transient state
Expand Down
12 changes: 6 additions & 6 deletions layers/+themes/colors/funcs.el
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@
(delq 'font-lock-keyword-face
rainbow-identifiers-faces-to-override)))

(defun colors//tweak-theme-colors (theme)
(defun colors//tweak-theme-colors ()
"Tweak color themes by adjusting rainbow-identifiers."
(interactive)
;; tweak the saturation and lightness of identifier colors
(unless (assq theme (get 'rainbow-identifiers-cie-l*a*b*-saturation
'theme-value))
(let ((sat&light (assq theme colors-theme-identifiers-sat&light)))
(unless (assq spacemacs--cur-theme
(get 'rainbow-identifiers-cie-l*a*b*-saturation
'theme-value))
(let ((sat&light (assq spacemacs--cur-theme colors-theme-identifiers-sat&light)))
(if sat&light
(setq rainbow-identifiers-cie-l*a*b*-saturation (cadr sat&light)
rainbow-identifiers-cie-l*a*b*-lightness (caddr sat&light))
Expand Down Expand Up @@ -162,4 +162,4 @@ Example usage:
"Refresh and re-apply the look of your current theme.
Always run this after adding new per-theme settings!"
(interactive)
(colors//tweak-theme-colors spacemacs--cur-theme))
(colors//tweak-theme-colors))
6 changes: 2 additions & 4 deletions layers/+themes/colors/packages.el
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,7 @@
font-lock-keyword-face
font-lock-function-name-face
font-lock-variable-name-face))
(define-advice spacemacs/post-theme-init (:after (&rest _) colors/post-theme-init)
"Adjust lightness and brightness of rainbow-identifiers on post theme init."
(colors//tweak-theme-colors spacemacs--cur-theme))
(add-hook 'spacemacs-post-theme-change-hook #'colors//tweak-theme-colors)
;; key bindings
(spacemacs/declare-prefix "Ci" "colors-identifiers")
(spacemacs|add-toggle rainbow-identifier
Expand All @@ -122,7 +120,7 @@
(spacemacs/set-leader-keys "Cis" 'colors/start-change-color-saturation)
(spacemacs/set-leader-keys "Cil" 'colors/start-change-color-lightness)
;; tweak colors of current theme
(colors//tweak-theme-colors spacemacs--cur-theme)
(colors//tweak-theme-colors)
(when (eq 'all colors-colorize-identifiers)
(global-rainbow-identifiers-mode))))

Expand Down

0 comments on commit b141a15

Please sign in to comment.