From 4283ccdd2c39ae482ca2dbc46936300329cf7dda Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sun, 14 Mar 2021 23:48:40 -0500 Subject: Further configure the mode line I've broken out extra functions into `acdw-modeline', so they don't clutter up the init.el too much. --- init.el | 56 +++++------------------------------ lisp/acdw-modeline.el | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+), 48 deletions(-) create mode 100644 lisp/acdw-modeline.el diff --git a/init.el b/init.el index 3e5210e..aa2039e 100644 --- a/init.el +++ b/init.el @@ -302,63 +302,23 @@ ;;; Mode line ;; Minions -(acdw/pkg minions - :now ((minions-mode +1))) +(acdw/pkg minions) ;; Simple mode line (acdw/pkg simple-modeline :set '((simple-modeline-segments ((;; left - acdw/modeline-modified - simple-modeline-segment-buffer-name - simple-modeline-segment-position) + acdw-modeline/modified + acdw-modeline/buffer-name + simple-modeline-segment-position + simple-modeline-segment-word-count) (;; right - simple-modeline-segment-vc + acdw-modeline/vc-branch simple-modeline-segment-misc-info simple-modeline-segment-process - acdw/modeline-minions + acdw-modeline/minions simple-modeline-segment-major-mode)))) - :now ((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 - (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)))) - (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))) + :now ((require 'acdw-modeline) (simple-modeline-mode +1))) ;;; 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 @@ +:;;; acdw-modeline.el -*- lexical-binding: t; coding: utf-8-unix -*- +;; +;; Author: Case Duckworth +;; 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) -- cgit 1.4.1-21-gabe81