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
|
;;; feebleline.el --- Replace modeline with a slimmer proxy
;; Copyright 2018 Benjamin Lindqvist
;; Author: Benjamin Lindqvist <benjamin.lindqvist@gmail.com>
;; Maintainer: Benjamin Lindqvist <benjamin.lindqvist@gmail.com>
;; URL: https://github.com/tautologyclub/feebleline
;; Package-Version:
;; Version: 1.0
;; This file is not part of GNU Emacs.
;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; For hardline Luddite editing!
;; Feebleline removes the modeline and replaces it with a slimmer proxy
;; version, which displays some basic information in the echo area
;; instead. This information is only displayed if the echo area is not used
;; for anything else (but if you switch frame/window, it will replace whatever
;; message is currently displayed).
;; To customize feebleline's format, modify `feebleline-mode-line-text'.
;; NOTE:
;; feebleline.el will look considerably better with the following
;; settings:
;; (window-divider-mode t)
;; (setq window-divider-default-bottom-width 1)
;; (setq window-divider-default-places (quote bottom-only))
;; But this mode does not work for all EMACS versions and may not work with
;; terminal EMACS (but I haven't checked). If you're on GUI EMACS and your
;; version supports it, just place the following in your init file:
;; (feebleline-default-settings)
;; Otherwise, do (feebleline-mode t) instead, but be warned that I'm not sure
;; if it will look good.
;;; Code:
(require 'advice)
(defvar feebleline/mode-line-format-default)
(defvar feebleline/timer)
(defface feebleline-time-face '((t :inherit 'default :foreground "#73d217"))
"Feebleline timestamp face."
:group 'feebleline-mode)
(defface feebleline-linum-face '((t :inherit 'default))
"Feebleline linum face."
:group 'feebleline-mode)
(defface feebleline-filename-face '((t :foreground "#fce94e"))
"Feebleline filename face."
:group 'feebleline-mode)
;; Note: ugly parentheses, for the simple reason that it makes it easier to
;; transpose, add and comment out lines.
(defvar feebleline-mode-line-text
'(
("[%s] " ((format-time-string "%H:%M:%S")) (face feebleline-time-face))
("(%s" ((string-to-number (format-mode-line "%l"))) (face feebleline-linum-face))
("%s" ("," ) (face default))
("%s) " ((current-column)) (face feebleline-linum-face))
("%s" ("") (face default))
("%s " ((buffer-file-name)) (face feebleline-filename-face))
)
"Each element is a list with the following format:
(FORMAT-STRING FORMAT-ARGS PROPS)
FORMAT-STRING will be used as the first argument to `format', and
FORMAT-ARGS (a list) will be expanded as the rest of `format'
arguments. If PROPS is given, it should be a list which will be
sent to `add-text-properties'.")
(defun feebleline-default-settings ()
"Some default settings that works well with feebleline."
(custom-set-variables
'(window-divider-default-bottom-width 1)
'(window-divider-default-places (quote bottom-only)))
(window-divider-mode t)
(feebleline-mode t))
(define-minor-mode feebleline-mode
"Replace modeline with a slimmer proxy."
:global t
(if feebleline-mode
(progn
(setq feebleline/mode-line-format-default mode-line-format)
(setq feebleline/timer (run-with-timer 0 0.1 'feebleline-mode-line-proxy-fn))
(custom-set-variables '(mode-line-format nil))
(ad-activate 'handle-switch-frame)
(add-hook 'focus-in-hook 'feebleline-mode-line-proxy-fn))
(custom-set-variables
'(mode-line-format feebleline/mode-line-format-default))
(cancel-timer feebleline/timer)
(ad-deactivate 'handle-switch-frame)
(remove-hook 'focus-in-hook 'feebleline-mode-line-proxy-fn)))
(defun feebleline--mode-line-part (part)
"Return a PART (an element) of `feebleline-mode-line-text` as a propertized string."
(let ((text (apply #'format (append (list (car part))
(mapcar #'eval (cadr part)))))
(props (elt part 2)))
(when props
(add-text-properties 0 (length text) props text))
text))
(defun feebleline-message-buffer-file-name-or-nothing ()
"Replace echo-area message with mode-line proxy."
(when buffer-file-name
(let ((message-log-max nil))
(message (mapconcat #'feebleline--mode-line-part feebleline-mode-line-text "")))))
(defun feebleline-mode-line-proxy-fn ()
"Put a mode-line proxy in the echo area *if* echo area is empty."
(unless (current-message)
(feebleline-message-buffer-file-name-or-nothing)))
(defadvice handle-switch-frame (after switch-frame-message-name)
"Get the modeline proxy to work with i3 switch focus."
(feebleline-message-buffer-file-name-or-nothing)
ad-do-it
(feebleline-message-buffer-file-name-or-nothing))
(provide 'feebleline)
;;; feebleline.el ends here
|