diff options
author | Case Duckworth | 2021-03-12 17:22:32 -0600 |
---|---|---|
committer | Case Duckworth | 2021-03-12 17:22:32 -0600 |
commit | 32800720dddb0061cd8f4187091f29c6088e5415 (patch) | |
tree | c3f6c3207bcb89636ae6ba0028f212064311ae04 | |
parent | Configure `org-mode'. (diff) | |
download | emacs-32800720dddb0061cd8f4187091f29c6088e5415.tar.gz emacs-32800720dddb0061cd8f4187091f29c6088e5415.zip |
Move `acdw/modeline' functions into `acdw/pkg' forms
This change means I don't have to `require' libraries that haven't been registered with `straight' yet.
-rw-r--r-- | init.el | 63 | ||||
-rw-r--r-- | lisp/acdw.el | 44 |
2 files changed, 52 insertions, 55 deletions
diff --git a/init.el b/init.el index 849cd24..2f8760f 100644 --- a/init.el +++ b/init.el | |||
@@ -307,17 +307,58 @@ | |||
307 | 307 | ||
308 | ;; Simple mode line | 308 | ;; Simple mode line |
309 | (acdw/pkg simple-modeline | 309 | (acdw/pkg simple-modeline |
310 | :now ((acdw/set '((simple-modeline-segments | 310 | :set '((simple-modeline-segments |
311 | ((;; left | 311 | ((;; left |
312 | acdw/modeline-modified | 312 | acdw/modeline-modified |
313 | simple-modeline-segment-buffer-name | 313 | simple-modeline-segment-buffer-name |
314 | simple-modeline-segment-position) | 314 | simple-modeline-segment-position) |
315 | (;; right | 315 | (;; right |
316 | simple-modeline-segment-vc | 316 | simple-modeline-segment-vc |
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 () | ||
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))) | ||
321 | (simple-modeline-mode +1))) | 362 | (simple-modeline-mode +1))) |
322 | 363 | ||
323 | ;;; Magit | 364 | ;;; Magit |
diff --git a/lisp/acdw.el b/lisp/acdw.el index b1843c9..201db1f 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el | |||
@@ -21,9 +21,6 @@ | |||
21 | ;; | 21 | ;; |
22 | ;;; Code: | 22 | ;;; Code: |
23 | 23 | ||
24 | (require 'simple-modeline) | ||
25 | (require 'minions) | ||
26 | |||
27 | ;;; Utilities | 24 | ;;; Utilities |
28 | 25 | ||
29 | (defun acdw/when-unfocused (func &rest args) | 26 | (defun acdw/when-unfocused (func &rest args) |
@@ -54,47 +51,6 @@ Ready for use with `after-focus-change-function'." | |||
54 | (run-at-time sunset-time (* 60 60 24) sunset-command) | 51 | (run-at-time sunset-time (* 60 60 24) sunset-command) |
55 | (run-at-time "12:00am" (* 60 60 24) sunset-command))) | 52 | (run-at-time "12:00am" (* 60 60 24) sunset-command))) |
56 | 53 | ||
57 | ;;; Mode line segments (for `simple-modeline') | ||
58 | (defun acdw/modeline-modified () | ||
59 | "Displays a color-coded buffer modification/read-only indicator in the mode-line." | ||
60 | (if (not (string-match-p "\\*.*\\*" (buffer-name))) | ||
61 | (let* ((read-only (and buffer-read-only (buffer-file-name))) | ||
62 | (modified (buffer-modified-p))) | ||
63 | (propertize | ||
64 | (if read-only " ×" (if modified " ●" " ○")) | ||
65 | 'face `(:inherit | ||
66 | ,(if modified 'simple-modeline-status-modified | ||
67 | (if read-only 'simple-modeline-status-error | ||
68 | 'simple-modeline-unimportant))) | ||
69 | 'help-echo (format | ||
70 | "Buffer is %s and %smodified\nmouse-1: Toggle read-only status." | ||
71 | (if read-only "read-only" "writable") | ||
72 | (if modified "" "not ")) | ||
73 | 'local-map (purecopy (simple-modeline-make-mouse-map | ||
74 | 'mouse-1 | ||
75 | (lambda (event) | ||
76 | (interactive "e") | ||
77 | (with-selected-window (posn-window (event-start event)) | ||
78 | (read-only-mode 'toggle))))) | ||
79 | 'mouse-face 'mode-line-highlight)))) | ||
80 | |||
81 | (defun acdw/modeline-minions () | ||
82 | "Display a button for `minions-minor-modes-menu'." | ||
83 | (concat | ||
84 | " " | ||
85 | (propertize | ||
86 | "ⱷ" | ||
87 | 'help-echo (format | ||
88 | "Minor modes menu\nmouse-1: show menu.") | ||
89 | 'local-map (purecopy (simple-modeline-make-mouse-map | ||
90 | 'mouse-1 | ||
91 | (lambda (event) | ||
92 | (interactive "e") | ||
93 | (with-selected-window (posn-window (event-start | ||
94 | event)) | ||
95 | (minions-minor-modes-menu))))) | ||
96 | 'mouse-face 'mode-line-highlight))) | ||
97 | |||
98 | ;;; Directories (think `no-littering') | 54 | ;;; Directories (think `no-littering') |
99 | 55 | ||
100 | (defvar acdw/dir (expand-file-name | 56 | (defvar acdw/dir (expand-file-name |