aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaul Benencia <rul@kalgan.cc>2022-04-11 16:58:38 -0700
committerRaul Benencia <rul@kalgan.cc>2022-04-11 16:59:23 -0700
commit881b5393073ec106b49f76bb39d62fff377ce9fb (patch)
treefa6997daea885ca9f0a022880702548a29b3dcfc
parentda1cb8e6e21a6dabc8720355ce3bb3bd8a721960 (diff)
emacs: customize tab-bar
-rw-r--r--.emacs2
-rw-r--r--.emacs.local.d/general.el3
-rw-r--r--.emacs.local.d/modes/hydra.el2
-rw-r--r--.emacs.local.d/modes/tabbar.el70
4 files changed, 72 insertions, 5 deletions
diff --git a/.emacs b/.emacs
index 98f804e..b4dbfff 100644
--- a/.emacs
+++ b/.emacs
@@ -14,7 +14,6 @@
(load-file "~/.emacs.local.d/modes/imenu.el")
(load-file "~/.emacs.local.d/modes/ivy.el")
(load-file "~/.emacs.local.d/modes/latex.el")
-(load-file "~/.emacs.local.d/modes/lsp.el")
(load-file "~/.emacs.local.d/modes/mail-mode.el")
(load-file "~/.emacs.local.d/modes/markdown.el")
(load-file "~/.emacs.local.d/modes/magit.el")
@@ -24,6 +23,7 @@
(load-file "~/.emacs.local.d/modes/projectile.el")
(load-file "~/.emacs.local.d/modes/python.el")
(load-file "~/.emacs.local.d/modes/sml.el")
+(load-file "~/.emacs.local.d/modes/tabbar.el")
(load-file "~/.emacs.local.d/modes/writeroom.el")
(load-file "~/.emacs.local.d/modes/themes.el")
diff --git a/.emacs.local.d/general.el b/.emacs.local.d/general.el
index 862f356..293ed2f 100644
--- a/.emacs.local.d/general.el
+++ b/.emacs.local.d/general.el
@@ -45,9 +45,6 @@
(global-set-key (kbd "C-c d") 'diff-buffer-with-file)
(global-set-key (kbd "C-c R") 'revert-buffer)
-(global-set-key (kbd "C-<next>") 'next-buffer)
-(global-set-key (kbd "C-<prior>") 'previous-buffer)
-
;; compile
(global-set-key [f12] 'compile)
diff --git a/.emacs.local.d/modes/hydra.el b/.emacs.local.d/modes/hydra.el
index 412970b..071581b 100644
--- a/.emacs.local.d/modes/hydra.el
+++ b/.emacs.local.d/modes/hydra.el
@@ -57,7 +57,7 @@ _s-f_: file _a_: ag _i_: Ibuffer _c_: cache
("t" tab-new "Create a new tab" :column "Creation")
("d" dired-other-tab "Open Dired in another tab")
("f" find-file-other-tab "Find file in another tab")
- ("0" tab-close "Close current tab")
+ ("x" tab-close "Close current tab")
("m" tab-move "Move current tab" :column "Management")
("r" tab-rename "Rename Tab")
("<return>" tab-bar-select-tab-by-name "Select tab by name" :column "Navigation")
diff --git a/.emacs.local.d/modes/tabbar.el b/.emacs.local.d/modes/tabbar.el
new file mode 100644
index 0000000..bd01174
--- /dev/null
+++ b/.emacs.local.d/modes/tabbar.el
@@ -0,0 +1,70 @@
+;; Inherit the face of `doom-modeline-panel` for better appearance
+(set-face-attribute 'tab-bar-tab nil :inherit 'doom-modeline-panel :foreground nil :background nil)
+
+;; Totally customize the format of the tab bar name
+(defun my/tab-bar-format (tab i)
+ (propertize
+ (format
+ (concat
+ (if (eq (car tab) 'current-tab)
+ "🔥 " "")
+ "%s")
+ (alist-get 'name tab))
+ 'face (list (append
+ '(:foreground "#FFFFFF")
+ (if (eq (car tab) 'current-tab)
+ '(:box t)
+ '())))))
+
+(global-set-key (kbd "C-<next>") 'tab-bar-switch-to-next-tab)
+(global-set-key (kbd "C-<prior>") 'tab-bar-switch-to-prev-tab)
+
+;; Replace the default tab bar function
+(setq tab-bar-tab-name-format-function #'my/tab-bar-format)
+
+(defun my/tab-bar-tab-name-function ()
+ "Return project name if in a project, or default tab-bar name if not.
+The default tab-bar name uses the buffer name."
+ (let ((project-name (projectile-project-name)))
+ (if (string= "-" project-name)
+ (tab-bar-tab-name-current)
+ (projectile-project-name))))
+
+(setq tab-bar-tab-name-function #'my/tab-bar-tab-name-function)
+
+;; Only show the tab bar if there are 2 or more tabs
+(setq tab-bar-show 1)
+
+(defun my/tab-bar-string () "HELLO")
+
+;; Customize the tab bar format to add the global mode line string
+(setq tab-bar-format '(tab-bar-format-tabs tab-bar-separator tab-bar-format-align-right tab-bar-format-global))
+
+(add-to-list 'global-mode-string "HELLO")
+
+;; Make sure mode line text in the tab bar can be read
+(set-face-attribute 'tab-bar nil :foreground "#FFFFFF")
+
+(defun my/project-create-tab ()
+ (interactive)
+ (tab-bar-new-tab)
+ (magit-status))
+
+(setq project-switch-commands #'my/project-create-tab)
+
+(defun my/switch-to-tab-buffer ()
+ (interactive)
+ (if (project-current)
+ (call-interactively #'projectile-switch-to-buffer)
+ (call-interactively #'switch-to-buffer)))
+
+(global-set-key (kbd "C-x b") #'my/switch-to-tab-buffer)
+
+;; Turn on tab bar mode after startup
+(tab-bar-mode 1)
+
+;; Save the desktop session
+(desktop-save-mode 1)
+
+
+(setq tab-bar-new-tab-choice "*dashboard*")
nihil fit ex nihilo