diff --git a/README.md b/README.md index bd8343f..86e8ebd 100644 --- a/README.md +++ b/README.md @@ -148,16 +148,24 @@ Strongly recommend to use ;; Please refer to https://github.com/bbatsov/projectile/issues/657. (setq doom-modeline-buffer-file-name-style 'truncate-upto-project) -;; Whether display icons or not (if nil nothing will be showed). +;; Whether display icons in mode-line or not. (setq doom-modeline-icon t) ;; Whether display the icon for major mode. It respects `doom-modeline-icon'. (setq doom-modeline-major-mode-icon t) -;; Display color icons for `major-mode'. It respects `all-the-icons-color-icons'. +;; Whether display color icons for `major-mode'. It respects +;; `doom-modeline-icon' and `all-the-icons-color-icons'. (setq doom-modeline-major-mode-color-icon t) -;; Whether display minor modes or not. Non-nil to display in mode-line. +;; Whether display icons for buffer states. It respects `doom-modeline-icon'. +(setq doom-modeline-buffer-state-icon t) + +;; Whether display buffer modification icon. It respects `doom-modeline-icon' +;; and `doom-modeline-buffer-state-icon'. +(setq doom-modeline-buffer-modification-icon t) + +;; Whether display minor modes in mode-line or not. (setq doom-modeline-minor-modes nil) ;; If non-nil, a word count will be added to the selection-info modeline segment. diff --git a/doom-modeline-core.el b/doom-modeline-core.el index c599d8e..9a28256 100644 --- a/doom-modeline-core.el +++ b/doom-modeline-core.el @@ -117,19 +117,22 @@ Given ~/Projects/FOSS/emacs/lisp/comint.el buffer-name => comint.el<2> (uniquify buffer name)") (defvar doom-modeline-icon (display-graphic-p) - "Whether show `all-the-icons' or not. - -Non-nil to show the icons in mode-line. -The icons may not be showed correctly in terminal.") + "Whether display icons in mode-line or not.") (defvar doom-modeline-major-mode-icon t - "Whether show the icon for major mode. It respects `doom-modeline-icon'.") + "Whether display the icon for major mode. It respects `doom-modeline-icon'.") (defvar doom-modeline-major-mode-color-icon t - "Display color icons for `major-mode'. It respects `all-the-icons-color-icons'.") + "Whether display color icons for `major-mode'. It respects `doom-modeline-icon' and `all-the-icons-color-icons'.") + +(defvar doom-modeline-buffer-state-icon t + "Whether display icons for buffer states. It respects `doom-modeline-icon'.") + +(defvar doom-modeline-buffer-modification-icon t + "Whether display buffer modification icon. It respects `doom-modeline-icon' and `doom-modeline-buffer-state-icon'.") (defvar doom-modeline-minor-modes nil - "Whether display minor modes or not. Non-nil to display in mode-line.") + "Whether display minor modes in mode-line or not.") (defvar doom-modeline-enable-word-count nil "If non-nil, a word count will be added to the selection-info modeline segment.") @@ -212,7 +215,7 @@ The icons may not be showed correctly in terminal.") (defface doom-modeline-panel '((t (:inherit mode-line-highlight))) "Face for 'X out of Y' segments, such as `anzu', `evil-substitute' - and`iedit', etc.") + and`iedit', etc.") (defface doom-modeline-info `((t (:inherit (success bold)))) @@ -320,14 +323,14 @@ The icons may not be showed correctly in terminal.") (defun doom-modeline-def-modeline (name lhs &optional rhs) "Defines a modeline format and byte-compiles it. -NAME is a symbol to identify it (used by `doom-modeline' for retrieval). -LHS and RHS are lists of symbols of modeline segments defined with -`doom-modeline-def-segment'. + NAME is a symbol to identify it (used by `doom-modeline' for retrieval). + LHS and RHS are lists of symbols of modeline segments defined with + `doom-modeline-def-segment'. -Example: + Example: (doom-modeline-def-modeline 'minimal - '(bar matches \" \" buffer-info) - '(media-info major-mode)) + '(bar matches \" \" buffer-info) + '(media-info major-mode)) (doom-modeline-set-modeline 'minimal t)" (let ((sym (intern (format "doom-modeline-format--%s" name))) (lhs-forms (doom-modeline--prepare-segments lhs)) @@ -351,14 +354,14 @@ Example: (defun doom-modeline (key) "Return a mode-line configuration associated with KEY (a symbol). -Throws an error if it doesn't exist." + Throws an error if it doesn't exist." (let ((fn (intern-soft (format "doom-modeline-format--%s" key)))) (when (functionp fn) `(:eval (,fn))))) (defun doom-modeline-set-modeline (key &optional default) "Set the modeline format. Does nothing if the modeline KEY doesn't exist. -If DEFAULT is non-nil, set the default mode-line for all buffers." + If DEFAULT is non-nil, set the default mode-line for all buffers." (when-let ((modeline (doom-modeline key))) (setf (if default (default-value 'mode-line-format) @@ -509,7 +512,7 @@ If DEFAULT is non-nil, set the default mode-line for all buffers." (defvar-local doom-modeline-project-root nil) (defun doom-modeline-project-root () "Get the path to the root of your project. -Return `default-directory' if no project was found." + Return `default-directory' if no project was found." (or doom-modeline-project-root (setq doom-modeline-project-root (file-local-name @@ -547,7 +550,7 @@ Return `default-directory' if no project was found." if (= d 0) collect (string-to-char " ") else collect (string-to-char ".")) (if (eq idx len) "\"};" "\",\n"))))) - 'xpm t :ascent 'center))))) + 'xpm t :ascent 'center))))) ;; Fix: invalid-regexp "Trailing backslash" while handling $HOME on Windows (defun doom-modeline-shrink-path--dirs-internal (full-path &optional truncate-all) diff --git a/doom-modeline-segments.el b/doom-modeline-segments.el index 95fda88..63eac3d 100644 --- a/doom-modeline-segments.el +++ b/doom-modeline-segments.el @@ -231,13 +231,14 @@ buffer where knowing the current project directory is important." "Displays an ICON with FACE, HEIGHT and VOFFSET. TEXT is the alternative if it is not applicable. Uses `all-the-icons-material' to fetch the icon." - (if doom-modeline-icon - (when icon - (doom-modeline-icon-material - icon - :face face - :height (or height 1.1) - :v-adjust (or voffset -0.225))) + (if (and doom-modeline-icon + doom-modeline-buffer-state-icon + icon) + (doom-modeline-icon-material + icon + :face face + :height (or height 1.1) + :v-adjust (or voffset -0.225)) (when text (propertize text 'face face)))) @@ -250,7 +251,8 @@ Uses `all-the-icons-material' to fetch the icon." "lock" "%1*" 'doom-modeline-warning)) - ((and buffer-file-name (buffer-modified-p)) + ((and buffer-file-name (buffer-modified-p) + doom-modeline-buffer-modification-icon) (doom-modeline-buffer-file-state-icon "save" "%1*"