-
Notifications
You must be signed in to change notification settings - Fork 0
/
mk_mode-line.el
80 lines (54 loc) · 2.07 KB
/
mk_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
;;; mk_mode-line.el --- Config for the mode line
;;; Commentary:
;; Config examples:
;; https://emacs.stackexchange.com/questions/13652/how-to-customize-mode-line-format
;;
;;; Code:
(display-time) ;; display time and load level every minute
(defun mk/state-appearance-on-modeline ()
"Select face for the different Evil states."
(if (equal 'normal evil-state)
'font-lock-constant-face
'font-lock-builtin-face))
(defun mk/truncate-string-to-width (str max-width)
"Truncate STR to MAX-WIDTH."
(if (> (string-width str) max-width)
(concat (truncate-string-to-width (substring str 0 -1)
max-width) "…")
str))
(setq-default mode-line-format
(list
"%e" ;print error mess on full memory
mode-line-front-space
'(:eval (propertize "%b " 'face 'font-lock-keyword-face
'help-echo (buffer-file-name))) ;tool tip
'(vc-mode vc-mode)
;; note that the eval is necessary to update state
'(:eval (propertize evil-mode-line-tag 'face
(mk/state-appearance-on-modeline)))
"(" ;; '%02' to set to 2 chars at least; prevents flickering
(propertize "%02l" 'face 'font-lock-type-face) "," ; line number
(propertize "%02c" 'face 'font-lock-type-face) ; column number
") "
"%I" ;; file size
" "
;; Major mode
"["
'(:eval (propertize "%m" 'face 'font-lock-string-face))
;; was this buffer modified since the last save?
'(:eval (when (buffer-modified-p)
(concat "," (propertize "Mod"
'face 'font-lock-warning-face
'help-echo "Buffer has been modified"))))
;; is this buffer read-only?
'(:eval (when buffer-read-only
(concat "," (propertize "RO"
'face 'font-lock-type-face
'help-echo "Buffer is read-only"))))
"]"
(propertize " || " 'face 'font-lock-constant-face)
'(:eval (mk/truncate-string-to-width (format-mode-line mode-line-misc-info) 20))
"%-" ;; fill with '-'
))
(provide 'mk_mode-line)
;;; mk_mode-line.el ends here