summaryrefslogtreecommitdiff
path: root/.config/emacs/modules/bd--tabs.el
blob: 533ce1a646998acf579267ec8fc5aca02cdd7d7a (plain)
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
;; -*- lexical-binding: t; -*-


;; turn tabs on, undo/redo mode
(setq tab-bar-show 1)
(tab-bar-history-mode)


;; remove useless gui elements
(setopt tab-bar-format
        '(tab-bar-format-tabs)
        tab-bar-close-button-show nil)


;; bind tabs to 'Meta' like other applications
(mapcar (lambda (i)
          (keymap-global-set (format "M-%d" i)
                             (lambda ()
                               (interactive)
                               (tab-bar-select-tab i))))
        (number-sequence 0 9))


;; use project name if it exists
(defun bd/tab-bar-name-function ()
  (let ((project (project-current)))
    (if project
        (car (last
              (file-name-split
               (directory-file-name
                (project-root project)))))
      (tab-bar-tab-name-current))))

(setopt project-switch-commands
        '((project-find-file "Find file")
          (project-find-regexp "Find regexp")
          (project-find-dir "Find directory")
          (magit-project-status "Magit")
          (project-shell "Shell")))

(keymap-global-set "C-x p v" 'magit-project-status)


(setq tab-bar-tab-name-function #'bd/tab-bar-name-function)


(provide 'bd--tabs)