-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbecker-mode-line.el
254 lines (215 loc) · 9.09 KB
/
becker-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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
;; Mode line setup
;; Format for time string
(setq display-time-string-forms
'((propertize (concat " TIME: " 24-hours ":" minutes " " am-pm))))
(setq-default
mode-line-format
'(
;; 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 " ")))
;; emacsclient [default -- keep?]
mode-line-client
" "
" "
;; 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)
;; Position, including warning for 80 columns
(:propertize "Line: %4l" face mode-line-position-face)
(:eval
(propertize " Col: %3c" 'face
(if (>= (current-column) 80)
'mode-line-80col-face
'mode-line-position-face)))
" %["
(: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)
" "
(:eval (propertize " " 'display '((space :align-to (- right-fringe 16)))))
(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 "Orange" ;;Yellow"
:background "Blue2"
:inverse-video nil
:weight 'bold
:box '(:line-width 6 :color "orange" :style nil))
(set-face-attribute 'mode-line-inactive nil
:foreground "white";"gray80"
:background "gray60"
:inverse-video nil
:box '(:line-width 6 :color "black" :style nil))
(set-face-attribute 'mode-line-read-only-face nil
:inherit 'mode-line-mode-face
:foreground "white"
:box '(:line-width 6 :color "orange")
:weight 'bold)
(set-face-attribute 'mode-line-modified-face nil
:inherit 'mode-line-mode-face
:foreground "#c82829"
;:background "#ffffff"
:box '(:line-width 6 :color "orange"))
(set-face-attribute 'mode-line-folder-face nil
:inherit 'mode-line-mode-face
:foreground "white" ;"gray60"
:weight 'bold)
(set-face-attribute 'mode-line-filename-face nil
:inherit 'mode-line-mode-face
:foreground "#eab700"
:weight 'extra-bold)
(set-face-attribute 'mode-line-position-face nil
:inherit 'mode-line-mode-face
:family "DejaVu Sans Mono"
:height 120)
(set-face-attribute 'mode-line-mode-face nil
;;:inherit 'mode-line-mode-face
:foreground "gray80")
(set-face-attribute 'mode-line-minor-mode-face nil
:inherit 'mode-line-mode-face
:foreground "orange" ;;"gray40"
:family "DejaVu Sans Mono"
:height 140)
(set-face-attribute 'mode-line-process-face nil
:inherit 'mode-line-mode-face
:foreground "#718c00"
:height 140)
(set-face-attribute 'mode-line-80col-face nil
:inherit 'mode-line-position-face
:foreground "black"
:background "#eab700")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; Nice mode line with arrows
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun arrow-right-xpm (color1 color2)
"Return an XPM right arrow string representing."
(format "/* XPM */
static char * arrow_right[] = {
\"12 18 2 1\",
\". c %s\",
\" c %s\",
\". \",
\".. \",
\"... \",
\".... \",
\"..... \",
\"...... \",
\"....... \",
\"........ \",
\"......... \",
\"......... \",
\"........ \",
\"....... \",
\"...... \",
\"..... \",
\".... \",
\"... \",
\".. \",
\". \"};" color1 color2))
(defun arrow-left-xpm (color1 color2)
"Return an XPM right arrow string representing."
(format "/* XPM */
static char * arrow_right[] = {
\"12 18 2 1\",
\". c %s\",
\" c %s\",
\" .\",
\" ..\",
\" ...\",
\" ....\",
\" .....\",
\" ......\",
\" .......\",
\" ........\",
\" .........\",
\" .........\",
\" ........\",
\" .......\",
\" ......\",
\" .....\",
\" ....\",
\" ...\",
\" ..\",
\" .\"};" color2 color1))
(defvar mode-line-show-minor-modes nil)
;; (let* ((color1 "RoyalBlue") ;; "#777777")
;; (color2 "Blue")) ;; "#555555"))
;; (setq arrow-right-1 (create-image (arrow-right-xpm color1 color2) 'xpm t :ascent 'center))
;; (setq arrow-right-2 (create-image (arrow-right-xpm color2 "None") 'xpm t :ascent 'center))
;; (setq arrow-left-1 (create-image (arrow-left-xpm color2 color1) 'xpm t :ascent 'center))
;; (setq arrow-left-2 (create-image (arrow-left-xpm "None" color2) 'xpm t :ascent 'center))
;; (setq-default mode-line-format
;; (list '(:eval (concat (propertize " %* %I %b" 'face 'mode-line-color-1)
;; (propertize " " 'display arrow-right-1)))
;; '(:eval (concat (propertize " %[%m%] " 'face 'mode-line-color-2
;; 'mouse-face 'mode-line-color-2
;; 'local-map (make-mode-line-mouse-map
;; 'mouse-1 (lambda () (interactive)
;; (setq mode-line-show-minor-modes
;; (not mode-line-show-minor-modes))
;; (redraw-modeline))))
;; (propertize " " 'display arrow-right-2)))
;; '(:eval (if mode-line-show-minor-modes mode-line-modes
;; global-mode-string))
;; ;; Justify right by filling with spaces to right fringe - 16
;; ;; (16 should be computed rahter than hardcoded)
;; '(:eval (propertize " " 'display '((space :align-to (- right-fringe 20)))))
;; '(:eval (concat (propertize " " 'display arrow-left-2)
;; (propertize " %6p " 'face 'mode-line-color-2)))
;; '(:eval (concat (propertize " " 'display arrow-left-1)
;; (propertize "%4l:%2c " 'face 'mode-line-color-1)))
;; ))
;; (make-face 'mode-line-color-1)
;; (set-face-attribute 'mode-line-color-1 nil
;; :foreground "#fff"
;; :background color1)
;; (make-face 'mode-line-color-2)
;; (set-face-attribute 'mode-line-color-2 nil
;; :foreground "#fff"
;; :background color2)
;; (set-face-attribute 'mode-line nil
;; :foreground "#fff"
;; :background "#2b2b2b"
;; :box nil)
;; (set-face-attribute 'mode-line-inactive nil
;; :foreground "#fff"
;; :background color2))