diff options
-rw-r--r-- | init.el | 56 | ||||
-rw-r--r-- | lisp/acdw-modeline.el | 82 |
2 files changed, 90 insertions, 48 deletions
diff --git a/init.el b/init.el index 3e5210e..aa2039e 100644 --- a/init.el +++ b/init.el | |||
@@ -302,63 +302,23 @@ | |||
302 | ;;; Mode line | 302 | ;;; Mode line |
303 | 303 | ||
304 | ;; Minions | 304 | ;; Minions |
305 | (acdw/pkg minions | 305 | (acdw/pkg minions) |
306 | :now ((minions-mode +1))) | ||
307 | 306 | ||
308 | ;; Simple mode line | 307 | ;; Simple mode line |
309 | (acdw/pkg simple-modeline | 308 | (acdw/pkg simple-modeline |
310 | :set '((simple-modeline-segments | 309 | :set '((simple-modeline-segments |
311 | ((;; left | 310 | ((;; left |
312 | acdw/modeline-modified | 311 | acdw-modeline/modified |
313 | simple-modeline-segment-buffer-name | 312 | acdw-modeline/buffer-name |
314 | simple-modeline-segment-position) | 313 | simple-modeline-segment-position |
314 | simple-modeline-segment-word-count) | ||
315 | (;; right | 315 | (;; right |
316 | simple-modeline-segment-vc | 316 | acdw-modeline/vc-branch |
317 | simple-modeline-segment-misc-info | 317 | simple-modeline-segment-misc-info |
318 | simple-modeline-segment-process | 318 | simple-modeline-segment-process |
319 | acdw/modeline-minions | 319 | acdw-modeline/minions |
320 | simple-modeline-segment-major-mode)))) | 320 | simple-modeline-segment-major-mode)))) |
321 | :now ((defun acdw/modeline-modified () | 321 | :now ((require 'acdw-modeline) |
322 | "Displays a color-coded buffer modification/read-only | ||
323 | indicator in the mode-line." | ||
324 | (if (not (string-match-p "\\*.*\\*" (buffer-name))) | ||
325 | (let* ((read-only (and buffer-read-only (buffer-file-name))) | ||
326 | (modified (buffer-modified-p))) | ||
327 | (propertize | ||
328 | (if read-only " ×" (if modified " ●" " ○")) | ||
329 | 'face `(:inherit | ||
330 | ,(if modified 'simple-modeline-status-modified | ||
331 | (if read-only 'simple-modeline-status-error | ||
332 | 'simple-modeline-unimportant))) | ||
333 | 'help-echo (format | ||
334 | (concat "Buffer is %s and %smodified\n" | ||
335 | "mouse-1: Toggle read-only status.") | ||
336 | (if read-only "read-only" "writable") | ||
337 | (if modified "" "not ")) | ||
338 | 'local-map (purecopy (simple-modeline-make-mouse-map | ||
339 | 'mouse-1 | ||
340 | (lambda (event) | ||
341 | (interactive "e") | ||
342 | (with-selected-window | ||
343 | (posn-window (event-start event)) | ||
344 | (read-only-mode 'toggle))))) | ||
345 | 'mouse-face 'mode-line-highlight)))) | ||
346 | (defun acdw/modeline-minions () | ||
347 | "Display a button for `minions-minor-modes-menu'." | ||
348 | (concat | ||
349 | " " | ||
350 | (propertize | ||
351 | "ⱷ" | ||
352 | 'help-echo (format | ||
353 | "Minor modes menu\nmouse-1: show menu.") | ||
354 | 'local-map (purecopy (simple-modeline-make-mouse-map | ||
355 | 'mouse-1 | ||
356 | (lambda (event) | ||
357 | (interactive "e") | ||
358 | (with-selected-window (posn-window | ||
359 | (event-start event)) | ||
360 | (minions-minor-modes-menu))))) | ||
361 | 'mouse-face 'mode-line-highlight))) | ||
362 | (simple-modeline-mode +1))) | 322 | (simple-modeline-mode +1))) |
363 | 323 | ||
364 | ;;; Magit | 324 | ;;; Magit |
diff --git a/lisp/acdw-modeline.el b/lisp/acdw-modeline.el new file mode 100644 index 0000000..89037f9 --- /dev/null +++ b/lisp/acdw-modeline.el | |||
@@ -0,0 +1,82 @@ | |||
1 | :;;; acdw-modeline.el -*- lexical-binding: t; coding: utf-8-unix -*- | ||
2 | ;; | ||
3 | ;; Author: Case Duckworth <acdw@acdw.net> | ||
4 | ;; Created: Sometime during Covid-19, 2020 | ||
5 | ;; Keywords: configuration | ||
6 | ;; URL: https://tildegit.org/acdw/emacs | ||
7 | ;; | ||
8 | ;; This file is NOT part of GNU Emacs. | ||
9 | ;; | ||
10 | ;;; License: | ||
11 | ;; | ||
12 | ;; Everyone is permitted to do whatever with this software, without | ||
13 | ;; limitation. This software comes without any warranty whatsoever, | ||
14 | ;; but with two pieces of advice: | ||
15 | ;; - Don't hurt yourself. | ||
16 | ;; - Make good choices. | ||
17 | ;; | ||
18 | ;;; Commentary: | ||
19 | ;; `acdw-modeline' is a dumping ground for extra modeline functions, so they | ||
20 | ;; don't clutter up `init.el'. | ||
21 | ;; | ||
22 | ;;; Code: | ||
23 | |||
24 | (require 'simple-modeline) | ||
25 | (require 'minions) | ||
26 | |||
27 | ;; modified from `simple-modeline' | ||
28 | (defun acdw-modeline/modified () | ||
29 | "Displays a color-coded buffer modification/read-only | ||
30 | indicator in the mode-line." | ||
31 | (if (not (string-match-p "\\*.*\\*" (buffer-name))) | ||
32 | (let* ((read-only (and buffer-read-only (buffer-file-name))) | ||
33 | (modified (buffer-modified-p))) | ||
34 | (propertize | ||
35 | (if read-only " =" (if modified " +" " -")) | ||
36 | 'help-echo (format | ||
37 | (concat "Buffer is %s and %smodified\n" | ||
38 | "mouse-1: Toggle read-only status.") | ||
39 | (if read-only "read-only" "writable") | ||
40 | (if modified "" "not ")) | ||
41 | 'local-map (purecopy (simple-modeline-make-mouse-map | ||
42 | 'mouse-1 | ||
43 | (lambda (event) | ||
44 | (interactive "e") | ||
45 | (with-selected-window | ||
46 | (posn-window (event-start event)) | ||
47 | (read-only-mode 'toggle))))) | ||
48 | 'mouse-face 'mode-line-highlight)))) | ||
49 | |||
50 | ;; all me, baby | ||
51 | (defun acdw-modeline/minions () | ||
52 | "Display a button for `minions-minor-modes-menu'." | ||
53 | (concat | ||
54 | " " | ||
55 | (propertize | ||
56 | "&" | ||
57 | 'help-echo (format | ||
58 | "Minor modes menu\nmouse-1: show menu.") | ||
59 | 'local-map (purecopy (simple-modeline-make-mouse-map | ||
60 | 'mouse-1 | ||
61 | (lambda (event) | ||
62 | (interactive "e") | ||
63 | (with-selected-window (posn-window | ||
64 | (event-start event)) | ||
65 | (minions-minor-modes-menu))))) | ||
66 | 'mouse-face 'mode-line-highlight))) | ||
67 | |||
68 | ;; from https://www.gonsie.com/blorg/modeline.html, from Doom | ||
69 | (defun acdw-modeline/vc-branch () | ||
70 | (let ((backend (vc-backend buffer-file-name))) | ||
71 | (substring vc-mode (+ (if (eq backend 'Hg) 2 3) 2)))) | ||
72 | |||
73 | ;; from gonsie | ||
74 | (defun acdw-modeline/buffer-name () | ||
75 | (propertize " %b " | ||
76 | 'face | ||
77 | (if (buffer-modified-p) | ||
78 | 'font-lock-warning-face | ||
79 | 'font-lock-type-face) | ||
80 | 'help-echo (buffer-file-name))) | ||
81 | |||
82 | (provide 'acdw-modeline) | ||