diff --git a/mood-line.el b/mood-line.el index 13f0f7f..0f613be 100644 --- a/mood-line.el +++ b/mood-line.el @@ -87,6 +87,38 @@ :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 any `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)))) + +(defcustom mood-line-meow-state-alist + '((normal . ("" . font-lock-variable-name-face)) + (insert . ("" . font-lock-string-face)) + (keypad . ("" . font-lock-keyword-face)) + (beacon . ("" . font-lock-type-face)) + (motion . ("" . font-lock-constant-face))) + "Set the string and corresponding face for any `meow-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 the `buffer-name'." @@ -303,6 +335,33 @@ The modeline should fit the `window-width' with space between the lists." (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 (boundp '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-segment-meow () + "Display the current meow-mode state." + (when (boundp 'meow--current-state) + (let ((mode-cons (alist-get + meow--current-state + mood-line-meow-state-alist))) + (concat (propertize (car mode-cons) 'face (cdr mode-cons)) " ")))) + +(defun mood-line-segment-god () + "Indicate whether or not god-mode is active." + (if (bound-and-true-p god-local-mode) + '(:propertize " " + face (:inherit mood-line-status-warning)) + "--- ")) + +(defun mood-line-segment-modal () + "Call the correct mode-line segment when the first modal-mode is found." + (cond ((bound-and-true-p evil-mode) (mood-line-segment-evil)) + ((bound-and-true-p meow-mode) (mood-line-segment-meow)) + ((featurep 'god-mode) (mood-line-segment-god)))) + ;; ;; Activation function ;; @@ -344,6 +403,7 @@ The modeline should fit the `window-width' with space between the lists." ;; Left (format-mode-line '(" " + (:eval (mood-line-segment-modal)) (:eval (mood-line-segment-modified)) (:eval (mood-line-segment-buffer-name)) (:eval (mood-line-segment-anzu))