summaryrefslogtreecommitdiff
path: root/.config/emacs/modules/bd--modeline.el
blob: 15b470f9d59469e55bef45e99983417708360b1d (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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
;;; -*- lexical-binding: t; -*-
;;; Commentary:
;;; Code:


;;;; remove all the stupid stupid stupid crap
(define-minor-mode minor-mode-blackout-mode
  "Hides minor modes from the mode line."
  t)

(catch 'done
  (mapc (lambda (x)
          (when (and (consp x)
                     (equal (cadr x) '("" minor-mode-alist)))
            (let ((original (copy-sequence x)))
              (setcar x 'minor-mode-blackout-mode)
              (setcdr x (list "" original)))
            (throw 'done t)))
        mode-line-modes))
(global-set-key (kbd "C-c ,") 'minor-mode-blackout-mode)

(defface bd/underline-shadow
  `((t :inherit shadow
       :bold t))
  "Shadow with an underline.")

(defvar-local bd/buffer-identification-mode-line
    '(:eval (format "%s" (propertize (buffer-name) 'face 'bd/underline-shadow)))
  "Formats the modeline-buffer-name.")

;;;; pos
(column-number-mode)
(setopt mode-line-position-column-line-format '(" %l:%c "))
(defvar-local bd/line-position
    '(:eval
      (when (mode-line-window-selected-p)
        ;; remove the percentage
        (cdr mode-line-position))))

;;;; git
(defun git-vc-modeline ()
  (mapconcat 'concat (cdr (split-string vc-mode "[:-]")) "-"))

(defvar-local bd/vc-mode-line
    '(:eval (when (and vc-mode (not (eq major-mode 'magit-status-mode)))
              (format " %s "
                      (propertize (git-vc-modeline) 'face 'shadow))))
  "Formats the checked out git repository.")


(dolist (construct '(bd/buffer-identification-mode-line
                     bd/vc-mode-line))
  (put construct 'risky-local-variable t))


(setq-default mode-line-format
              (list
               mode-line-front-space
               bd/buffer-identification-mode-line
	       " -- "
               mode-line-modes
	       " -- "
	       bd/vc-mode-line
	       " -- "
               bd/line-position))


(provide 'bd--modeline)
;;; bd-modeline ends here