forked from jyp/boon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
boon-powerline.el
88 lines (80 loc) · 5.2 KB
/
boon-powerline.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
;;; boon-powerline.el --- An Ergonomic Command Mode -*- lexical-binding: t -*-
;;; Commentary:
;; This module gives an example setup for powerline using boon.
;;; Code:
(require 'powerline nil t)
(require 'boon-core)
(defface boon-modeline-cmd '((((background light)) :background "dodger blue") (((background dark)) :background "blue")) "Face for modeline indicator of boon command state" :group 'boon)
(defface boon-modeline-ins '((((background light)) :background "indian red") (((background dark)) :background "red")) "Face for modeline indicator of boon insert state" :group 'boon)
(defface boon-modeline-off '((t (:background "orange"))) "Face for modeline indicator of boon off state" :group 'boon)
(defface boon-modeline-spc '((((background light)) :background "spring green") (((background dark)) :background "dark green")) "Face for modeline indicator of boon special state" :group 'boon)
(defun boon-state-face ()
"Return a face appropriate for a powerline-style entry in the modeline."
(cond
(boon-command-state 'boon-modeline-cmd)
(boon-insert-state 'boon-modeline-ins)
(boon-special-state 'boon-modeline-spc)
(t 'boon-modeline-off)))
(defun boon-powerline-theme ()
"Set up a powerline based on powerline-default-theme which also displays boon-state."
(interactive)
(setq-default mode-line-format
'("%e"
(:eval
(let* ((active (powerline-selected-window-active))
(mode-line (if active 'mode-line 'mode-line-inactive))
(face0 (if active (boon-state-face) 'mode-line-inactive))
(face1 (if active 'powerline-active1 'powerline-inactive1))
(face2 (if active 'powerline-active2 'powerline-inactive2))
(separator-left (intern (format "powerline-%s-%s"
powerline-default-separator
(car powerline-default-separator-dir))))
(separator-right (intern (format "powerline-%s-%s"
powerline-default-separator
(cdr powerline-default-separator-dir))))
(boon (when (bound-and-true-p boon-mode)
(list
(powerline-raw " " face0)
(powerline-raw (boon-state-string) face0 'r)
(funcall separator-left face0 mode-line)
)))
(lhs (list
(powerline-raw (if (buffer-modified-p) "*" "-" ) mode-line 'l)
(powerline-raw mode-line-mule-info mode-line)
(powerline-buffer-id mode-line 'l)
(when (and (boundp 'which-func-mode) which-func-mode)
(powerline-raw which-func-format mode-line 'l))
(powerline-raw " " mode-line)
(funcall separator-left mode-line face1)
(when (boundp 'erc-modified-channels-object)
(powerline-raw erc-modified-channels-object face1 'l))
(powerline-major-mode face1 'l)
(powerline-process face1)
(powerline-minor-modes face1 'l)
(powerline-narrow face1 'l)
(powerline-raw " " face1)
(funcall separator-left face1 face2)
(powerline-vc face2 'r)))
(rhs (list (powerline-raw global-mode-string face2 'r)
(funcall separator-right face2 face1)
(powerline-raw "%l" face1 'l)
(powerline-raw ":" face1)
(powerline-raw "%c" face1 'r)
(funcall separator-right face1 mode-line)
(powerline-raw " " mode-line)
(powerline-raw "%p" mode-line)
(powerline-raw " " mode-line)
(if (eq major-mode 'pdf-view-mode)
(concat "p"(number-to-string (pdf-view-current-page))
"/"
(number-to-string (pdf-cache-number-of-pages)) " "))
(powerline-buffer-size mode-line nil)
(powerline-raw " " mode-line)
(powerline-hud mode-line face1)
)))
(concat (powerline-render boon)
(powerline-render lhs)
(powerline-fill face2 (powerline-width rhs))
(powerline-render rhs)))))))
(provide 'boon-powerline)
;;; boon-powerline.el ends here