From eeff72172b7fee20c18c42f0440e08b433db98f3 Mon Sep 17 00:00:00 2001 From: Vincent Zhang Date: Fri, 4 Jan 2019 00:21:40 +0800 Subject: [PATCH] [Feature] Support nyan cat in position segment. --- README.md | 1 + doom-modeline.el | 36 +++++++++++++++++++++--------------- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 8577b4f..7c5d00c 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,7 @@ The `doom-modeline` was designed for minimalism, and offers: - An indicator for current input method - An indicator for `LSP` state - An indicator for github notifications +- An indicator for buffer position which is compatible with `nyan-mode` - Truncated file name, file icon, buffer state and project name in buffer information segment, which is compatible with `projectile` and `project` diff --git a/doom-modeline.el b/doom-modeline.el index 1620060..4fdac50 100644 --- a/doom-modeline.el +++ b/doom-modeline.el @@ -4,7 +4,7 @@ ;; Author: Vincent Zhang ;; Homepage: https://github.com/seagle0128/doom-modeline -;; Version: 1.4.1 +;; Version: 1.4.2 ;; Package-Requires: ((emacs "25.1") (all-the-icons "1.0.0") (shrink-path "0.2.0") (eldoc-eval "0.1") (dash "2.11.0")) ;; Keywords: faces mode-line @@ -54,6 +54,7 @@ ;; - An indicator for debug state ;; - An indicator for LSP state ;; - An indicator for github notifications +;; - An indicator for buffer position which is compatible with nyan-mode ;; - Truncated file name, file icon, buffer state and project name in buffer ;; information segment, which is compatible with projectile and project ;; @@ -1711,23 +1712,28 @@ See `mode-line-percent-position'.") (when (eq op 'set) (setq doom-modeline-percent-position val))))) -(setq-default mode-line-position - '((line-number-mode - (column-number-mode - (doom-modeline-column-zero-based " %l:%c" " %l:%C") - " %l") - (column-number-mode (doom-modeline-column-zero-based " :%c" " :%C"))) - (if doom-modeline-percent-position (" " doom-modeline-percent-position)) - (:eval (when (or line-number-mode column-number-mode doom-modeline-percent-position) " ")))) - (doom-modeline-def-segment buffer-position "The buffer position information." - `(:propertize (concat " " mode-line-position) - help-echo "Buffer position\n\ + (let ((lc '(line-number-mode + (column-number-mode + (doom-modeline-column-zero-based " %l:%c" " %l:%C") + " %l") + (column-number-mode (doom-modeline-column-zero-based " :%c" " :%C"))))) + (if (bound-and-true-p nyan-mode) + (concat " " (nyan-create) " " + (propertize (format-mode-line lc) + 'help-echo "Buffer position\n\ mouse-1: Display Line and Column Mode Menu" - mouse-face (:box 1) - local-map ,mode-line-column-line-number-mode-map)) - + 'mouse-face '(:box 1) + 'local-map mode-line-column-line-number-mode-map)) + `(:propertize (" " + (if doom-modeline-percent-position (" " doom-modeline-percent-position)) + ,lc + (when (or line-number-mode column-number-mode doom-modeline-percent-position) " ")) + help-echo "Buffer position\n\ +mouse-1: Display Line and Column Mode Menu" + mouse-face (:box 1) + local-map ,mode-line-column-line-number-mode-map)))) ;; ;; evil-state