From 2140ded3deec9c472081184a6e7ccdb03a5be5f3 Mon Sep 17 00:00:00 2001 From: Vincent Zhang Date: Mon, 22 Apr 2019 23:35:52 +0800 Subject: [PATCH] [Enhancement] New modal segment. An indicator for modal editing state, including evil, god, ryo and xah-fly-keys, etc. --- README.md | 6 ++---- doom-modeline-segments.el | 34 +++++++++++++--------------------- doom-modeline.el | 10 ++++------ 3 files changed, 19 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index 86e8ebd..02fa832 100644 --- a/README.md +++ b/README.md @@ -24,10 +24,8 @@ The `doom-modeline` was designed for minimalism, and offers: - A workspace number segment for `eyebrowse` - A perspective name segment for `persp-mode` - A window number segment for `ace-window`, `winum` and `window-numbering` -- An indicator for `evil` state -- An indicator for `god` state -- An indicator for `ryo-modal` state -- An indicator for `xah-fly-keys` state +- An indicator for modal editing state, including `evil`, `god`, `ryo` and + `xah-fly-keys`, etc. - An indicator for remote host - An indicator for debug state - An indicator for current input method diff --git a/doom-modeline-segments.el b/doom-modeline-segments.el index 63eac3d..8ddf4fc 100644 --- a/doom-modeline-segments.el +++ b/doom-modeline-segments.el @@ -1399,10 +1399,10 @@ mouse-1: Display Line and Column Mode Menu" (concat " " (parrot-create) " "))) ;; -;; evil-state +;; modals (evil, god, ryo and xah-fly-keys, etc.) ;; -(doom-modeline-def-segment evil-state +(defsubst doom-modeline--evil () "The current evil state. Requires `evil-mode' to be enabled." (when (bound-and-true-p evil-local-mode) (let ((tag (evil-state-property evil-state :tag t))) @@ -1417,37 +1417,22 @@ mouse-1: Display Line and Column Mode Menu" ((evil-replace-state-p) 'doom-modeline-evil-replace-state)) 'mode-line-inactive))))) - -;; -;; god-state -;; - -(doom-modeline-def-segment god-state +(defsubst doom-modeline--god () "The current god state. Requires `god-mode' to be enabled." (when (bound-and-true-p god-local-mode) (propertize " " 'face (if (doom-modeline--active) 'doom-modeline-evil-normal-state 'mode-line-inactive)))) - -;; -;; ryo-modal state -;; - -(doom-modeline-def-segment ryo-modal () +(defsubst doom-modeline--ryo () "The current ryo-modal state. Requires `ryo-modal-mode' to be enabled." (when (bound-and-true-p ryo-modal-mode) (propertize " " 'face (if (doom-modeline--active) 'doom-modeline-evil-normal-state 'mode-line-inactive)))) - -;; -;; xah-fly-keys state -;; - -(doom-modeline-def-segment xah-fly-keys () - "The current xah-fly-keys state." +(defsubst doom-modeline--xah-fly-keys () + "The current `xah-fly-keys' state." (when (boundp 'xah-fly-insert-state-q) (propertize (if xah-fly-insert-state-q " " @@ -1456,6 +1441,13 @@ mouse-1: Display Line and Column Mode Menu" 'doom-modeline-evil-normal-state 'mode-line-inactive)))) +(doom-modeline-def-segment modals + "Displays modal editing states, including `evil', `god', `ryo' and `xha-fly-kyes', etc. " + (concat (doom-modeline--evil) + (doom-modeline--god) + (doom-modeline--ryo) + (doom-modeline--xah-fly-keys))) + ;; ;; input method ;; diff --git a/doom-modeline.el b/doom-modeline.el index a1c8c31..ce6c091 100644 --- a/doom-modeline.el +++ b/doom-modeline.el @@ -45,10 +45,8 @@ ;; - A workspace number segment for eyebrowse ;; - A perspective name segment for persp-mode ;; - A window number segment for winum and window-numbering -;; - An indicator for evil state -;; - An indicator for god state -;; - An indicator for ryo-modal state -;; - An indicator for xah-fly-keys state +;; - An indicator for modal editing state, including evil, god, ryo and +;; xah-fly-keys, etc. ;; - An indicator for remote host ;; - An indicator for current input method ;; - An indicator for debug state @@ -85,7 +83,7 @@ ;; (doom-modeline-def-modeline 'main - '(bar workspace-name window-number evil-state god-state ryo-modal xah-fly-keys matches buffer-info remote-host buffer-position parrot selection-info) + '(bar workspace-name window-number modals matches buffer-info remote-host buffer-position parrot selection-info) '(misc-info persp-name lsp irc mu4e github debug fancy-battery minor-modes input-method buffer-encoding major-mode process vcs checker)) (doom-modeline-def-modeline 'minimal @@ -93,7 +91,7 @@ '(media-info major-mode)) (doom-modeline-def-modeline 'special - '(bar window-number evil-state god-state ryo-modal xah-fly-keys matches buffer-info-simple buffer-position parrot selection-info) + '(bar window-number modals matches buffer-info-simple buffer-position parrot selection-info) '(misc-info lsp irc-buffers debug fancy-battery minor-modes input-method buffer-encoding major-mode process checker)) (doom-modeline-def-modeline 'project