blob: 1369d7d7959f1015c1bf934293a64656f26aab94 (
plain)
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
|
;;; acdw-modeline.el -*- lexical-binding: t; coding: utf-8-unix -*-
;; Author: Case Duckworth <acdw@acdw.net>
;; Created: Sometime during Covid-19, 2020
;; Keywords: configuration
;; URL: https://tildegit.org/acdw/emacs
;; This file is NOT part of GNU Emacs.
;;; License:
;; Everyone is permitted to do whatever with this software, without
;; limitation. This software comes without any warranty whatsoever,
;; but with two pieces of advice:
;; - Don't hurt yourself.
;; - Make good choices.
;;; Commentary:
;; `acdw-modeline' is a dumping ground for extra modeline functions, so they
;; don't clutter up `init.el'.
;;; Code:
(require 'simple-modeline)
(require 'minions)
;; modified from `simple-modeline'
(defun acdw-modeline/modified ()
"Displays a color-coded buffer modification/read-only
indicator in the mode-line."
(if (not (string-match-p "\\*.*\\*" (buffer-name)))
(let* ((read-only (and buffer-read-only (buffer-file-name)))
(modified (buffer-modified-p)))
(propertize
(if read-only " =" (if modified " +" " -"))
'help-echo (format
(concat "Buffer is %s and %smodified\n"
"mouse-1: Toggle read-only status.")
(if read-only "read-only" "writable")
(if modified "" "not "))
'local-map (purecopy (simple-modeline-make-mouse-map
'mouse-1
(lambda (event)
(interactive "e")
(with-selected-window
(posn-window (event-start event))
(read-only-mode 'toggle)))))
'mouse-face 'mode-line-highlight))))
;; all me, baby
(defun acdw-modeline/minions ()
"Display a button for `minions-minor-modes-menu'."
(concat
" "
(propertize
"&"
'help-echo (format
"Minor modes menu\nmouse-1: show menu.")
'local-map (purecopy (simple-modeline-make-mouse-map
'mouse-1
(lambda (event)
(interactive "e")
(with-selected-window (posn-window
(event-start event))
(minions-minor-modes-menu)))))
'mouse-face 'mode-line-highlight)))
;; from https://www.gonsie.com/blorg/modeline.html, from Doom
(defun acdw-modeline/vc-branch ()
(let ((backend (vc-backend buffer-file-name)))
(substring vc-mode (+ (if (eq backend 'Hg) 2 3) 2))))
;; from gonsie
(defun acdw-modeline/buffer-name ()
(propertize " %b "
'face
(if (buffer-modified-p)
'font-lock-warning-face
'font-lock-type-face)
'help-echo (buffer-file-name)))
(provide 'acdw-modeline)
|