From cabd4323dde11411c8285d927510cbc062486571 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Fri, 12 Mar 2021 09:36:15 -0600 Subject: Configure `simple-modeline' --- lisp/acdw.el | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'lisp') diff --git a/lisp/acdw.el b/lisp/acdw.el index 971eabe..3ae480d 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el @@ -21,6 +21,9 @@ ;; ;;; Code: +(require 'simple-modeline) +(require 'minions) + ;;; Utilities (defun acdw/when-unfocused (func &rest args) @@ -51,6 +54,47 @@ Ready for use with `after-focus-change-function'." (run-at-time sunset-time (* 60 60 24) sunset-command) (run-at-time "12:00am" (* 60 60 24) sunset-command))) +;;; Mode line segments (for `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 " ●" " ○")) + 'face `(:inherit + ,(if modified 'simple-modeline-status-modified + (if read-only 'simple-modeline-status-error + 'simple-modeline-unimportant))) + 'help-echo (format + "Buffer is %s and %smodified\nmouse-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)))) + +(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))) + ;;; Directories (think `no-littering') (defvar acdw/dir (expand-file-name -- cgit 1.4.1-21-gabe81