Skip to content

Commit

Permalink
[themes][keybindings] Use apt completion framework for loading theme
Browse files Browse the repository at this point in the history
Theme transient state key-binding `t` is broken if `ivy` completion framework is
used. The binding unconditionally invokes `helm-themes`.

This change adds a new function which takes care of invoking correct
theme-loader function based on completion framework currently in use.

The old binding used `helm-themes` but the new function uses already defined
`spacemacs/helm-themes` which removes the number of candidates limit.
  • Loading branch information
nixmaniack authored and aam-at committed Mar 23, 2021
1 parent 7b70a6a commit ee7cb81
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.develop
Original file line number Diff line number Diff line change
Expand Up @@ -907,8 +907,8 @@ Other:
- Move ~SPC t C p~ to ~SPC t h p~ for =highlight-parentheses-mode=
(thanks to Thomas de Beauchêne)
- New ~SPC t m r~ to toggle responsiveness of the mode-line
- New themes transient state key bindings ~t~ or ~<up>~ to open =helm-themes=
to select an installed theme (thanks to duianto)
- New themes transient state keys to list available themes: ~t~ or ~<up>~
(thanks to duianto and Muneeb Shaikh)
- Added ~SPC t z~ to toggle zero-based column indexing in the mode line
- New key binding and function ~SPC w d~ for =spacemacs/maximize-vertically
(thanks to Ag Ibragimov)
Expand Down
10 changes: 10 additions & 0 deletions core/core-themes-support.el
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,16 @@ When BACKWARD is non-nil, or with universal-argument, cycle backwards."
(setq spacemacs--cur-theme theme))
(spacemacs/post-theme-init theme)))

(defun spacemacs/theme-loader ()
"Call appropriate theme loader based on completion framework."
(interactive)
(cond
((configuration-layer/layer-used-p 'helm)
(call-interactively 'spacemacs/helm-themes))
((configuration-layer/layer-used-p 'ivy)
(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."
Expand Down
6 changes: 3 additions & 3 deletions layers/+spacemacs/spacemacs-defaults/keybindings.el
Original file line number Diff line number Diff line change
Expand Up @@ -223,13 +223,13 @@
;; Cycling settings -----------------------------------------------------------
(spacemacs|define-transient-state theme
:title "Themes Transient State"
:doc "\n[_n_/_<right>_] next [_N_/_p_/_<left>_] previous [_t_/_<up>_] helm-themes"
:doc "\n[_n_/_<right>_] next [_N_/_p_/_<left>_] previous [_t_/_<up>_] list themes"
:bindings
("n" spacemacs/cycle-spacemacs-theme)
("N" spacemacs/cycle-spacemacs-theme-backward)
("p" spacemacs/cycle-spacemacs-theme-backward)
("t" helm-themes)
("<up>" helm-themes)
("t" spacemacs/theme-loader)
("<up>" spacemacs/theme-loader)
("<right>" spacemacs/cycle-spacemacs-theme)
("<left>" spacemacs/cycle-spacemacs-theme-backward))
(spacemacs/set-leader-keys "Tn"
Expand Down

0 comments on commit ee7cb81

Please sign in to comment.