Skip to content

Commit

Permalink
fix: Handle load theme
Browse files Browse the repository at this point in the history
  • Loading branch information
jcs090218 committed Jun 27, 2024
1 parent 90b21c2 commit 9f04a13
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 20 deletions.
5 changes: 2 additions & 3 deletions Eask
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(package "centaur-tabs"
"5"
"3.3"
"Aesthetic, modern looking customizable tabs plugin")

(website-url "https://github.com/ema2159/centaur-tabs")
Expand All @@ -12,8 +12,7 @@
(source 'gnu)
(source 'melpa)

(depends-on "emacs" "24.4")
(depends-on "emacs" "26.1")
(depends-on "powerline")
(depends-on "cl-lib")

(setq network-security-level 'low) ; see https://github.com/jcs090218/setup-emacs-windows/issues/156#issuecomment-932956432
28 changes: 14 additions & 14 deletions centaur-tabs-elements.el
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

;;; Code:

(require 'custom)
(require 'color)
(require 'powerline)

Expand All @@ -40,14 +41,12 @@
;;; Faces

(defface centaur-tabs-default
'((t
(:background "black" :foreground "black")))
'((t (:background "black" :foreground "black")))
"Default face used in the tab bar."
:group 'centaur-tabs)

(defface centaur-tabs-unselected
'((t
(:background "#3D3C3D" :foreground "grey50")))
'((t (:background "#3D3C3D" :foreground "grey50")))
"Face used for unselected tabs."
:group 'centaur-tabs)

Expand All @@ -57,8 +56,7 @@
:group 'centaur-tabs)

(defface centaur-tabs-unselected-modified
'((t
(:background "#3D3C3D" :foreground "grey50")))
'((t (:background "#3D3C3D" :foreground "grey50")))
"Face used for unselected-modified tabs."
:group 'centaur-tabs)

Expand All @@ -68,8 +66,7 @@
:group 'centaur-tabs)

(defface centaur-tabs-close-unselected
'((t
(:inherit centaur-tabs-unselected)))
'((t (:inherit centaur-tabs-unselected)))
"Face used for unselected close button."
:group 'centaur-tabs)

Expand Down Expand Up @@ -877,12 +874,15 @@ Create one if the frame doesn't have one yet."

(defun centaur-tabs-select-separator-style (tab-style)
"Set the separator style to TAB-STYLE."
(setq centaur-tabs-style-left
(funcall (intern (format "powerline-%s-right" tab-style))
'centaur-tabs-default nil centaur-tabs-height))
(setq centaur-tabs-style-right
(funcall (intern (format "powerline-%s-left" tab-style)) nil
'centaur-tabs-default centaur-tabs-height)))
(let* ((theme (or (car custom-enabled-themes) "default"))
(name (intern (format "centaur-tabs--%s-face" theme)))
(face (copy-face 'centaur-tabs-default name)))
(setq centaur-tabs-style-left
(funcall (intern (format "powerline-%s-right" tab-style))
face nil centaur-tabs-height))
(setq centaur-tabs-style-right
(funcall (intern (format "powerline-%s-left" tab-style))
nil face centaur-tabs-height))))

(provide 'centaur-tabs-elements)
;;; centaur-tabs-elements.el ends here
14 changes: 14 additions & 0 deletions centaur-tabs-functions.el
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
(defvar centaur-tabs--buffer-show-groups)
(defvar centaur-tabs-ace-jump-active)

(declare-function centaur-tabs-mode "centaur-tabs.el")

;;
;;; Customs

Expand Down Expand Up @@ -557,6 +559,18 @@ hooked functions"
(centaur-tabs-set-template centaur-tabs-current-tabset nil)
(centaur-tabs-display-update))

(defun centaur-tabs-re-enable ()
"Re-enable `centaur-tabs-mode'."
(centaur-tabs-mode -1)
(centaur-tabs-mode 1))

(defun centaur-tabs--after-load-theme (&rest _)
"Function to be run after the theme changed."
(setq centaur-tabs-style-right nil
centaur-tabs-style-left nil)
;; XXX: Dirty hack, is there a way to improve this?
(centaur-tabs-re-enable))

;;
;;; Events and event functions

Expand Down
8 changes: 5 additions & 3 deletions centaur-tabs.el
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
;; Created: 2019-21-19 22:14:34
;; Version: 3.3
;; Known Compatibility: GNU Emacs 26.2
;; Package-Requires: ((emacs "26.1") (powerline "2.4") (cl-lib "0.5"))
;; Package-Requires: ((emacs "26.1") (powerline "2.4"))
;; Keywords: frames

;;; This file is NOT part of GNU Emacs
Expand Down Expand Up @@ -202,7 +202,8 @@ Run as `centaur-tabs-init-hook'."
(add-hook 'kill-buffer-hook #'centaur-tabs-buffer-track-killed)
(advice-add #'undo :after #'centaur-tabs-after-modifying-buffer)
(advice-add #'undo-tree-undo-1 :after #'centaur-tabs-after-modifying-buffer)
(advice-add #'undo-tree-redo-1 :after #'centaur-tabs-after-modifying-buffer))
(advice-add #'undo-tree-redo-1 :after #'centaur-tabs-after-modifying-buffer)
(advice-add 'load-theme :after #'centaur-tabs--after-load-theme))

(defun centaur-tabs-buffer-quit ()
"Quit tab bar buffer.
Expand All @@ -217,7 +218,8 @@ Run as `centaur-tabs-quit-hook'."
(remove-hook 'kill-buffer-hook 'centaur-tabs-buffer-track-killed)
(advice-remove #'undo #'centaur-tabs-after-modifying-buffer)
(advice-remove #'undo-tree-undo-1 #'centaur-tabs-after-modifying-buffer)
(advice-remove #'undo-tree-redo-1 #'centaur-tabs-after-modifying-buffer))
(advice-remove #'undo-tree-redo-1 #'centaur-tabs-after-modifying-buffer)
(advice-remove 'load-theme #'centaur-tabs--after-load-theme))

(add-hook 'centaur-tabs-init-hook #'centaur-tabs-buffer-init)
(add-hook 'centaur-tabs-quit-hook #'centaur-tabs-buffer-quit)
Expand Down

0 comments on commit 9f04a13

Please sign in to comment.