* mood-line.el: Added evil-mode support
Also laid some ground work for adding other modal editing systems. Moved the buffer modified segment, but only when some modal-editing mode is being used. It felt right to give modal-editing the front of the mode-line.
This commit is contained in:
parent
ef1c752679
commit
998cd7ec8e
35
mood-line.el
35
mood-line.el
@ -87,6 +87,23 @@
|
||||
:group 'mood-line
|
||||
:type 'boolean)
|
||||
|
||||
(defcustom mood-line-evil-state-alist
|
||||
'((normal . ("<N>" . font-lock-variable-name-face))
|
||||
(insert . ("<I>" . font-lock-string-face))
|
||||
(visual . ("<V>" . font-lock-keyword-face))
|
||||
(replace . ("<R>" . font-lock-type-face))
|
||||
(motion . ("<M>" . font-lock-constant-face))
|
||||
(operator . ("<O>" . font-lock-function-name-face))
|
||||
(emacs . ("<E>" . 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))))
|
||||
|
Loading…
Reference in New Issue
Block a user