about summary refs log tree commit diff stats
path: root/lisp
diff options
context:
space:
mode:
authorCase Duckworth2021-03-16 09:30:40 -0500
committerCase Duckworth2021-03-16 09:30:40 -0500
commitf17f0a6629c718a2433267ca898fe16d6e0ae868 (patch)
treef50ccbcab88dd1572977cb053c8e7b4b2870133a /lisp
parent"Package-ize" dired (diff)
parentInstall `no-littering' (diff)
downloademacs-f17f0a6629c718a2433267ca898fe16d6e0ae868.tar.gz
emacs-f17f0a6629c718a2433267ca898fe16d6e0ae868.zip
Merge branch 'main' of https://tildegit.org/acdw/emacs into 5c
Diffstat (limited to 'lisp')
-rw-r--r--lisp/acdw-modeline.el82
-rw-r--r--lisp/acdw.el27
2 files changed, 104 insertions, 5 deletions
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
30indicator 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)
diff --git a/lisp/acdw.el b/lisp/acdw.el index 84fcb99..e25de43 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el
@@ -145,20 +145,37 @@ otherwise it's wrapped in `kbd'.
145The following keywords are recognized: 145The following keywords are recognized:
146 146
147:after ARGS .. call `autoload' on COMMAND using ARGS before 147:after ARGS .. call `autoload' on COMMAND using ARGS before
148 binding the key. ARGS can be just the filename to 148 binding the key. ARGS can be just the filename to
149 load; in that case it's wrapped in a list. 149 load; in that case it's wrapped in a list.
150
150:map KEYMAP .. define KEY in KEYMAP instead of the 151:map KEYMAP .. define KEY in KEYMAP instead of the
151 default `acdw/bind-default-map'." 152 default `acdw/bind-default-map'. If `:after' is also supplied,
153 run `autoload' on KEYMAP (except when using `:map-after', see).
154
155:map-after FILE .. run the underlying `define-key' command in an
156 `with-eval-after-load'. For the rare occasion when the keymap is
157 defined in a different file than the command it binds (looking
158 at you, `org-mode')."
152 (let ((after (when-let (sym (plist-get args :after)) 159 (let ((after (when-let (sym (plist-get args :after))
153 (if (not (listp sym)) 160 (if (not (listp sym))
154 (list sym) 161 (list sym)
155 sym))) 162 sym)))
163 (map-after (plist-get args :map-after))
156 (keymap (or (plist-get args :map) acdw/bind-default-map)) 164 (keymap (or (plist-get args :map) acdw/bind-default-map))
157 (keycode (if (vectorp key) key (kbd key))) 165 (keycode (if (vectorp key) key (kbd key)))
158 (command-list)) 166 (command-list))
159 (push `(define-key ,keymap ,keycode ',command) command-list) 167 (let ((define-key-command `(define-key ,keymap ,keycode ',command)))
168 (if map-after
169 (push `(with-eval-after-load ,map-after
170 ,define-key-command)
171 command-list)
172 (push define-key-command command-list)))
160 (when after 173 (when after
161 (push `(autoload ',command ,@after) command-list)) 174 (unless (fboundp command)
175 (push `(autoload ',command ,@after) command-list))
176 (unless (or map-after
177 (eq keymap acdw/bind-default-map))
178 (push `(autoload ',keymap ,(car after) nil nil 'keymap) command-list)))
162 `(progn 179 `(progn
163 ,@command-list))) 180 ,@command-list)))
164 181