-
Notifications
You must be signed in to change notification settings - Fork 0
/
mode-line.el
111 lines (105 loc) · 3.68 KB
/
mode-line.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
;; Mode line setup
(setq-default
mode-line-format
'(; Position, including warning for 80 columns
(:propertize "%4l:" face mode-line-position-face)
(:eval (propertize "%3c" 'face
(if (>= (current-column) 80)
'mode-line-80col-face
'mode-line-position-face)))
; emacsclient [default -- keep?]
mode-line-client
" "
; read-only or modified status
(:eval
(cond (buffer-read-only
(propertize " RO " 'face 'mode-line-read-only-face))
((buffer-modified-p)
(propertize " ** " 'face 'mode-line-modified-face))
(t " ")))
" "
; directory and buffer/file name
(:propertize (:eval (shorten-directory default-directory 30))
face mode-line-folder-face)
(:propertize "%b"
face mode-line-filename-face)
; narrow [default -- keep?]
" %n "
; mode indicators: vc, recursive edit, major mode, minor modes, process, global
(vc-mode vc-mode)
" %["
(:propertize mode-name
face mode-line-mode-face)
"%] "
(:eval (propertize (format-mode-line minor-mode-alist)
'face 'mode-line-minor-mode-face))
(:propertize mode-line-process
face mode-line-process-face)
(global-mode-string global-mode-string)
" "
; nyan-mode uses nyan cat as an alternative to %p
(:eval (when nyan-mode (list (nyan-create))))
))
;; Helper function
(defun shorten-directory (dir max-length)
"Show up to `max-length' characters of a directory name `dir'."
(let ((path (reverse (split-string (abbreviate-file-name dir) "/")))
(output ""))
(when (and path (equal "" (car path)))
(setq path (cdr path)))
(while (and path (< (length output) (- max-length 4)))
(setq output (concat (car path) "/" output))
(setq path (cdr path)))
(when path
(setq output (concat ".../" output)))
output))
;; Extra mode line faces
(make-face 'mode-line-read-only-face)
(make-face 'mode-line-modified-face)
(make-face 'mode-line-folder-face)
(make-face 'mode-line-filename-face)
(make-face 'mode-line-position-face)
(make-face 'mode-line-mode-face)
(make-face 'mode-line-minor-mode-face)
(make-face 'mode-line-process-face)
(make-face 'mode-line-80col-face)
(set-face-attribute 'mode-line nil
:foreground "gray60" :background "gray20"
:inverse-video nil)
(set-face-attribute 'mode-line-inactive nil
:foreground "gray80" :background "gray40"
:inverse-video nil)
(set-face-attribute 'mode-line-read-only-face nil
:inherit 'mode-line-face
:foreground "#4271ae")
(set-face-attribute 'mode-line-modified-face nil
:inherit 'mode-line-face
:box nil
:foreground "#c82829"
:background "#ffffff")
(set-face-attribute 'mode-line-folder-face nil
:inherit 'mode-line-face
:foreground "#999")
(set-face-attribute 'mode-line-filename-face nil
:inherit 'mode-line-face
:foreground "#f0f0f0")
(set-face-attribute 'mode-line-position-face nil
:inherit 'mode-line-face
:height 120)
(set-face-attribute 'mode-line-mode-face nil
:inherit 'mode-line-face
:foreground "gray80")
;; This is the minor mode, such as whitespace-mode or paredit-mode
(set-face-attribute 'mode-line-minor-mode-face nil
:inherit 'mode-line-mode-face
:font "Visitor TT1 BRK"
:foreground "#d9d9d9"
:italic nil
:bold nil
:height 120)
(set-face-attribute 'mode-line-process-face nil
:inherit 'mode-line-face
:foreground "#718c00")
(set-face-attribute 'mode-line-80col-face nil
:inherit 'mode-line-position-face
:foreground "black" :background "#eab700")