From 356e8d670a38da81fe2d3f178cb659b6914197b7 Mon Sep 17 00:00:00 2001 From: Vincent Zhang Date: Tue, 14 May 2019 02:11:40 +0800 Subject: [PATCH] [Feature] options: doom-modeline-buffer-encoding and doom-modeline-indent-info. --- doom-modeline-core.el | 6 ++++++ doom-modeline-segments.el | 38 ++++++++++++++++++++------------------ 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/doom-modeline-core.el b/doom-modeline-core.el index cb27c2f..63949fd 100644 --- a/doom-modeline-core.el +++ b/doom-modeline-core.el @@ -149,6 +149,12 @@ Given ~/Projects/FOSS/emacs/lisp/comint.el (defvar doom-modeline-major-mode-color-icon t "Whether display color icons for `major-mode'. It respects `doom-modeline-icon' and `all-the-icons-color-icons'.") +(defvar doom-modeline-buffer-encoding t + "Whether display buffer encoding.") + +(defvar doom-modeline-indent-info nil + "Whether display indentation information.") + (defvar doom-modeline-buffer-state-icon t "Whether display icons for buffer states. It respects `doom-modeline-icon'.") diff --git a/doom-modeline-segments.el b/doom-modeline-segments.el index 29f22ae..61ce26a 100644 --- a/doom-modeline-segments.el +++ b/doom-modeline-segments.el @@ -419,21 +419,22 @@ directory, the file name, and its state (modified, read-only or non-existent)." (doom-modeline-def-segment buffer-encoding "Displays the encoding and eol style of the buffer the same way Atom does." - (propertize - (concat (pcase (coding-system-eol-type buffer-file-coding-system) - (0 " LF") - (1 " RLF") - (2 " CR")) - (let ((sys (coding-system-plist buffer-file-coding-system))) - (cond ((memq (plist-get sys :category) - '(coding-category-undecided coding-category-utf-8)) - " UTF-8 ") - (t (upcase (symbol-name (plist-get sys :name)))))) - " ") - 'face (if (doom-modeline--active) 'mode-line 'mode-line-inactive) - 'help-echo 'mode-line-mule-info-help-echo - 'mouse-face '(:box 0) - 'local-map mode-line-coding-system-map)) + (when doom-modeline-buffer-encoding + (propertize + (concat (pcase (coding-system-eol-type buffer-file-coding-system) + (0 " LF") + (1 " RLF") + (2 " CR")) + (let ((sys (coding-system-plist buffer-file-coding-system))) + (cond ((memq (plist-get sys :category) + '(coding-category-undecided coding-category-utf-8)) + " UTF-8 ") + (t (upcase (symbol-name (plist-get sys :name)))))) + " ") + 'face (if (doom-modeline--active) 'mode-line 'mode-line-inactive) + 'help-echo 'mode-line-mule-info-help-echo + 'mouse-face '(:box 0) + 'local-map mode-line-coding-system-map))) ;; @@ -442,9 +443,10 @@ directory, the file name, and its state (modified, read-only or non-existent)." (doom-modeline-def-segment indent-info "Displays the indentation information." - (propertize (format " %s %d " - (if indent-tabs-mode "TAB" "SPC") tab-width) - 'face (if (doom-modeline--active) 'mode-line 'mode-line-inactive))) + (when doom-modeline-indent-info + (propertize (format " %s %d " + (if indent-tabs-mode "TAB" "SPC") tab-width) + 'face (if (doom-modeline--active) 'mode-line 'mode-line-inactive)))) ;; ;; remote host