-
Notifications
You must be signed in to change notification settings - Fork 1
/
mustafa-tabbar-mode.el
65 lines (60 loc) · 2.03 KB
/
mustafa-tabbar-mode.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
;; tabbar mode customizations
;; taken from http://www.emacswiki.org/emacs/TabBarMode#toc12
(when (require 'tabbar nil t)
;; Enable tabbars globally:
(tabbar-mode 1)
;; I use this minor-mode mainly as a global mode (see below):
(define-minor-mode tabbar-on-custom-mode
"Display tabbar on selected modes only."
:init-value t
:lighter nil
:keymap nil
(if tabbar-on-custom-mode
;; filter is enabled
(if (memq major-mode '(term-mode
eshell-mode
dired-mode
help-mode
apropos-mode
Info-mode
Man-mode))
(tabbar-local-mode -1)
(tabbar-local-mode 1))
;; always activate tabbar locally when we disable the minor mode:
(tabbar-local-mode -1)))
(defun tabbar-on-custom-mode-on ()
"Turn on tabbar if current buffer is a terminal."
(unless (minibufferp) (tabbar-on-custom-mode 1)))
;; Define a global switch for the mode. Note that this is not set for buffers
;; in fundamental mode.
;;
;; I use it 'cause some major modes do not run the
;; `after-change-major-mode-hook'...
(define-globalized-minor-mode global-tabbar-on-custom-mode
tabbar-on-custom-mode tabbar-on-custom-mode-on)
;; Eventually, switch on this global filter for tabbars:
(global-tabbar-on-custom-mode 1))
(defun my-tabbar-buffer-groups ()
(list
(cond
((memq major-mode '(term-mode eshell-mode))
"Terminal")
((eq major-mode 'dired-mode)
"Dired"
)
((memq major-mode
'(help-mode apropos-mode Info-mode Man-mode))
"Help"
)
(t
;; Return `mode-name' if not blank, `major-mode' otherwise.
(if (and (stringp mode-name)
;; Take care of preserving the match-data because this
;; function is called when updating the header line.
(save-match-data (string-match "[^ ]" mode-name)))
mode-name
(symbol-name major-mode))
))))
(setq tabbar-buffer-groups-function 'my-tabbar-buffer-groups)
(setq tabbar-use-images nil)
(setq tabbar-background-color "#181818")