Fix #78: a new toggle for env version.

This commit is contained in:
Vincent Zhang 2018-12-31 22:55:23 +08:00
parent d453e780e4
commit 202a90e660
2 changed files with 8 additions and 2 deletions

View file

@ -162,6 +162,9 @@ Strongly recommend to use
;; The interval of checking github. ;; The interval of checking github.
(setq doom-modeline-github-interval (* 30 60)) (setq doom-modeline-github-interval (* 30 60))
;; Whether display environment version or not.
(setq doom-modeline-version t)
``` ```
## FAQ ## FAQ

View file

@ -137,6 +137,9 @@ The icons may not be showed correctly in terminal and on Windows.")
(defvar doom-modeline-github-interval (* 30 60) (defvar doom-modeline-github-interval (* 30 60)
"The interval of checking github.") "The interval of checking github.")
(defvar doom-modeline-version t
"Whether display environment version or not.")
;; ;;
;; Compatibilities ;; Compatibilities
@ -526,7 +529,7 @@ If DEFAULT is non-nil, set the default mode-line for all buffers."
(add-hook 'focus-in-hook #'doom-modeline-update-env))) (add-hook 'focus-in-hook #'doom-modeline-update-env)))
(defun doom-modeline-update-env () (defun doom-modeline-update-env ()
"Update environment info on mode-line." "Update environment info on mode-line."
(when doom-modeline-env-command (when (and doom-modeline-version doom-modeline-env-command)
(let ((default-directory (doom-modeline-project-root)) (let ((default-directory (doom-modeline-project-root))
(s (shell-command-to-string doom-modeline-env-command))) (s (shell-command-to-string doom-modeline-env-command)))
(setq doom-modeline-env-version (if (string-match "[ \t\n\r]+\\'" s) (setq doom-modeline-env-version (if (string-match "[ \t\n\r]+\\'" s)
@ -926,7 +929,7 @@ mouse-2: Show help for major mode\n\
mouse-3: Toggle minor modes" mouse-3: Toggle minor modes"
mouse-face mode-line-highlight mouse-face mode-line-highlight
local-map ,mode-line-major-mode-keymap)) local-map ,mode-line-major-mode-keymap))
(when doom-modeline-env-version (when (and doom-modeline-version doom-modeline-env-version)
(format " %s" doom-modeline-env-version)) (format " %s" doom-modeline-env-version))
(and (boundp 'text-scale-mode-amount) (and (boundp 'text-scale-mode-amount)
(/= text-scale-mode-amount 0) (/= text-scale-mode-amount 0)