2023-11-19 01:20:29 +00:00
|
|
|
;;; mood-line-segment-modal.el --- A modal editing status segment for mood-line -*- lexical-binding: t; -*-
|
2023-01-26 09:17:55 +00:00
|
|
|
;;
|
|
|
|
;; Author: trevDev() <trev@trevdev.ca>
|
|
|
|
;; Jessie Hildebrandt <jessieh.net>
|
|
|
|
;; Homepage: https://gitlab.com/jessieh/mood-line
|
2023-12-10 13:08:09 +00:00
|
|
|
;;
|
2023-01-26 09:17:55 +00:00
|
|
|
;; This file is not part of GNU Emacs.
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
;;
|
|
|
|
;; This segment displays modal editing information for the current buffer.
|
|
|
|
|
|
|
|
;;; License:
|
|
|
|
;;
|
|
|
|
;; This program is free software; you can redistribute it and/or
|
|
|
|
;; modify it under the terms of the GNU General Public License as
|
|
|
|
;; published by the Free Software Foundation; either version 2, or
|
|
|
|
;; (at your option) any later version.
|
|
|
|
;;
|
|
|
|
;; This program is distributed in the hope that it will be useful,
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
;; General Public License for more details.
|
|
|
|
;;
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
|
|
|
;; along with this program; see the file COPYING. If not, write to
|
|
|
|
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
|
|
|
;; Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
|
|
|
;; -------------------------------------------------------------------------- ;;
|
|
|
|
;;
|
|
|
|
;; Custom definitions
|
|
|
|
;;
|
|
|
|
;; -------------------------------------------------------------------------- ;;
|
|
|
|
|
2023-11-19 01:20:29 +00:00
|
|
|
;; ---------------------------------- ;;
|
|
|
|
;; Group definitions
|
|
|
|
;; ---------------------------------- ;;
|
|
|
|
|
|
|
|
(defgroup mood-line-segment-modal nil
|
|
|
|
"A modal editing status segment for mood-line."
|
|
|
|
:group 'mood-line)
|
|
|
|
|
2023-01-26 09:17:55 +00:00
|
|
|
;; ---------------------------------- ;;
|
|
|
|
;; Variable definitions
|
|
|
|
;; ---------------------------------- ;;
|
|
|
|
|
2023-11-19 01:20:29 +00:00
|
|
|
(defcustom mood-line-segment-modal-evil-state-alist
|
2023-01-26 09:17:55 +00:00
|
|
|
'((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)))
|
2023-11-19 01:20:29 +00:00
|
|
|
"Alist specifying indicators and faces for corresponding `evil-mode' states.
|
|
|
|
The face may be either a face symbol or a property list of key-value pairs;
|
|
|
|
e.g., (:foreground \"red\")."
|
|
|
|
:group 'mood-line-segment-modal
|
|
|
|
:type '(alist :key-type symbol
|
|
|
|
:value-type (cons (string :tag "Display text")
|
|
|
|
(choice :tag "Face" face plist))))
|
|
|
|
|
|
|
|
(defcustom mood-line-segment-modal-meow-state-alist
|
2023-01-26 09:17:55 +00:00
|
|
|
'((normal . ("<N>" . font-lock-variable-name-face))
|
|
|
|
(insert . ("<I>" . font-lock-string-face))
|
|
|
|
(keypad . ("<K>" . font-lock-keyword-face))
|
|
|
|
(beacon . ("<B>" . font-lock-type-face))
|
|
|
|
(motion . ("<M>" . font-lock-constant-face)))
|
2023-11-19 01:20:29 +00:00
|
|
|
"Alist specifying indicators and faces corresponding `meow-mode' states.
|
|
|
|
The face may be either a face symbol or a property list of key-value pairs;
|
|
|
|
e.g., (:foreground \"red\")."
|
|
|
|
:group 'mood-line-segment-modal
|
|
|
|
:type '(alist :key-type symbol
|
|
|
|
:value-type (cons (string :tag "Display text")
|
|
|
|
(choice :tag "Face" face plist))))
|
2023-01-26 09:17:55 +00:00
|
|
|
|
|
|
|
;; -------------------------------------------------------------------------- ;;
|
|
|
|
;;
|
2023-11-19 01:20:29 +00:00
|
|
|
;; Modal editing segments
|
2023-01-26 09:17:55 +00:00
|
|
|
;;
|
|
|
|
;; -------------------------------------------------------------------------- ;;
|
|
|
|
|
|
|
|
;; ---------------------------------- ;;
|
2023-11-19 01:20:29 +00:00
|
|
|
;; Evil segment
|
2023-01-26 09:17:55 +00:00
|
|
|
;; ---------------------------------- ;;
|
|
|
|
|
2023-11-19 01:20:29 +00:00
|
|
|
(defun mood-line-segment-modal--evil-fn ()
|
|
|
|
"Return the current `evil-mode' state."
|
2023-01-26 09:17:55 +00:00
|
|
|
(when (boundp 'evil-state)
|
2023-11-19 01:20:29 +00:00
|
|
|
(let ((mode-cons (alist-get evil-state
|
|
|
|
mood-line-segment-modal-evil-state-alist)))
|
2023-01-26 09:17:55 +00:00
|
|
|
(concat (propertize (car mode-cons)
|
2023-11-19 01:20:29 +00:00
|
|
|
'face (cdr mode-cons))))))
|
2023-01-26 09:17:55 +00:00
|
|
|
|
|
|
|
;; ---------------------------------- ;;
|
2023-11-19 01:20:29 +00:00
|
|
|
;; Meow segment
|
2023-01-26 09:17:55 +00:00
|
|
|
;; ---------------------------------- ;;
|
|
|
|
|
2023-11-19 01:20:29 +00:00
|
|
|
(defun mood-line-segment-modal--meow-fn ()
|
|
|
|
"Return the current `meow-mode' state."
|
2023-01-26 09:17:55 +00:00
|
|
|
(when (boundp 'meow--current-state)
|
2023-11-19 01:20:29 +00:00
|
|
|
(let ((mode-cons (alist-get meow--current-state
|
|
|
|
mood-line-segment-modal-meow-state-alist)))
|
2023-01-26 09:17:55 +00:00
|
|
|
(concat (propertize (car mode-cons)
|
2023-11-19 01:20:29 +00:00
|
|
|
'face (cdr mode-cons))))))
|
2023-01-26 09:17:55 +00:00
|
|
|
|
|
|
|
;; ---------------------------------- ;;
|
2023-12-09 11:10:01 +00:00
|
|
|
;; Xah segment
|
2023-01-26 09:17:55 +00:00
|
|
|
;; ---------------------------------- ;;
|
|
|
|
|
2023-12-09 11:10:01 +00:00
|
|
|
(defun mood-line-segment-modal--xah-fn ()
|
|
|
|
"Display the current xah-fly-keys state."
|
|
|
|
(if (bound-and-true-p xah-fly-insert-state-p)
|
|
|
|
"<I>"
|
|
|
|
"<C>"))
|
2023-01-26 09:17:55 +00:00
|
|
|
|
|
|
|
;; ---------------------------------- ;;
|
2023-11-19 01:20:29 +00:00
|
|
|
;; God segment
|
2023-01-26 09:17:55 +00:00
|
|
|
;; ---------------------------------- ;;
|
|
|
|
|
2023-11-19 01:20:29 +00:00
|
|
|
(defun mood-line-segment-modal--god-fn ()
|
|
|
|
"Return an indicator of whether or not `god-mode' is active."
|
2023-01-26 09:17:55 +00:00
|
|
|
(if (bound-and-true-p god-local-mode)
|
2023-11-19 01:20:29 +00:00
|
|
|
(propertize "<G>" 'face 'mood-line-status-warning)
|
|
|
|
"---"))
|
2023-01-26 09:17:55 +00:00
|
|
|
|
|
|
|
;; -------------------------------------------------------------------------- ;;
|
|
|
|
;;
|
|
|
|
;; Provide package
|
|
|
|
;;
|
|
|
|
;; -------------------------------------------------------------------------- ;;
|
|
|
|
|
|
|
|
(provide 'mood-line-segment-modal)
|
|
|
|
|
|
|
|
;;; mood-line-segment-modal.el ends here
|