diff --git a/mood-line.el b/mood-line.el index edfad36..9b69c0c 100644 --- a/mood-line.el +++ b/mood-line.el @@ -87,6 +87,23 @@ :group 'mood-line :type 'boolean) +(defcustom mood-line-evil-state-alist + '((normal . ("" . font-lock-variable-name-face)) + (insert . ("" . font-lock-string-face)) + (visual . ("" . font-lock-keyword-face)) + (replace . ("" . font-lock-type-face)) + (motion . ("" . font-lock-constant-face)) + (operator . ("" . font-lock-function-name-face)) + (emacs . ("" . font-lock-builtin-face))) + "Set the string and corresponding face for many `evil-mode' state. +The `Face' may be either a face symbol or a property list of key-value pairs + e.g. (:foreground \"red\")." + :group 'mood-line + :type '(alist + :key-type symbol + :value-type + (cons (string :tag "Display Text") (choice :tag "Face" face plist)))) + (defface mood-line-buffer-name '((t (:inherit (mode-line-buffer-id)))) "Face used for major mode indicator in the mode-line." @@ -303,6 +320,16 @@ (unless (string= (mood-line--string-trim process-info) "") (concat (mood-line--string-trim process-info) " ")))) +(defun mood-line-segment-evil () + "Display the current evil-mode state." + (when evil-state + (let ((mode-cons (alist-get evil-state mood-line-evil-state-alist))) + (concat (propertize (car mode-cons) 'face (cdr mode-cons)) " ")))) + +(defun mood-line--modal-editing-p () + "Determine if modal editing is being used." + (mood-line-segment-modified)) ; (or) is for future modal additions. + ;; ;; Activation function ;; @@ -343,8 +370,14 @@ ;; Left (format-mode-line '(" " - (:eval (mood-line-segment-modified)) + (:eval (if (mood-line--modal-editing-p) + (progn + (mood-line-segment-evil)) + (mood-line-segment-modified))) (:eval (mood-line-segment-buffer-name)) + (:eval (if (mood-line--modal-editing-p) + (concat + (mood-line-segment-modified) " "))) (:eval (mood-line-segment-anzu)) (:eval (mood-line-segment-multiple-cursors)) (:eval (mood-line-segment-position))))