mirror of
https://github.com/correl/doom-modeline.git
synced 2024-11-23 19:19:50 +00:00
Fix #154: shorten branch name of vcs segment.
This commit is contained in:
parent
eb5685a2b9
commit
c5b5a4d2d2
3 changed files with 15 additions and 4 deletions
|
@ -166,6 +166,9 @@ Strongly recommend to use
|
||||||
;; If non-nil, only display one number for checker information if applicable.
|
;; If non-nil, only display one number for checker information if applicable.
|
||||||
(setq doom-modeline-checker-simple-format t)
|
(setq doom-modeline-checker-simple-format t)
|
||||||
|
|
||||||
|
;; The maximum displayed length of the branch name of version control.
|
||||||
|
(setq doom-modeline-vcs-max-length 12)
|
||||||
|
|
||||||
;; Whether display perspective name or not. Non-nil to display in mode-line.
|
;; Whether display perspective name or not. Non-nil to display in mode-line.
|
||||||
(setq doom-modeline-persp-name t)
|
(setq doom-modeline-persp-name t)
|
||||||
|
|
||||||
|
|
|
@ -105,6 +105,9 @@ The icons may not be showed correctly in terminal.")
|
||||||
(defvar doom-modeline-checker-simple-format t
|
(defvar doom-modeline-checker-simple-format t
|
||||||
"If non-nil, only display one number for checker information if applicable.")
|
"If non-nil, only display one number for checker information if applicable.")
|
||||||
|
|
||||||
|
(defvar doom-modeline-vcs-max-length 12
|
||||||
|
"The maximum displayed length of the branch name of version control.")
|
||||||
|
|
||||||
(defvar doom-modeline-persp-name t
|
(defvar doom-modeline-persp-name t
|
||||||
"Whether display perspective name or not. Non-nil to display in mode-line.")
|
"Whether display perspective name or not. Non-nil to display in mode-line.")
|
||||||
|
|
||||||
|
|
|
@ -545,7 +545,7 @@ Uses `all-the-icons-octicon' to fetch the icon."
|
||||||
|
|
||||||
(defvar-local doom-modeline--vcs-icon nil)
|
(defvar-local doom-modeline--vcs-icon nil)
|
||||||
(defun doom-modeline-update-vcs-icon (&rest _)
|
(defun doom-modeline-update-vcs-icon (&rest _)
|
||||||
"Update icon of vsc state in mode-line."
|
"Update icon of vcs state in mode-line."
|
||||||
(setq doom-modeline--vcs-icon
|
(setq doom-modeline--vcs-icon
|
||||||
(when (and vc-mode buffer-file-name)
|
(when (and vc-mode buffer-file-name)
|
||||||
(let* ((backend (vc-backend buffer-file-name))
|
(let* ((backend (vc-backend buffer-file-name))
|
||||||
|
@ -583,12 +583,17 @@ Uses `all-the-icons-octicon' to fetch the icon."
|
||||||
|
|
||||||
(defvar-local doom-modeline--vcs-text nil)
|
(defvar-local doom-modeline--vcs-text nil)
|
||||||
(defun doom-modeline-update-vcs-text (&rest _)
|
(defun doom-modeline-update-vcs-text (&rest _)
|
||||||
"Update text of vsc state in mode-line."
|
"Update text of vcs state in mode-line."
|
||||||
(setq doom-modeline--vcs-text
|
(setq doom-modeline--vcs-text
|
||||||
(when (and vc-mode buffer-file-name)
|
(when (and vc-mode buffer-file-name)
|
||||||
(let* ((backend (vc-backend buffer-file-name))
|
(let* ((backend (vc-backend buffer-file-name))
|
||||||
(state (vc-state buffer-file-name backend)))
|
(state (vc-state buffer-file-name backend))
|
||||||
(propertize (substring vc-mode (+ (if (eq backend 'Hg) 2 3) 2))
|
(str (substring vc-mode (+ (if (eq backend 'Hg) 2 3) 2))))
|
||||||
|
(propertize (if (> (length str) doom-modeline-vcs-max-length)
|
||||||
|
(concat
|
||||||
|
(substring str 0 (- doom-modeline-vcs-max-length 3))
|
||||||
|
"...")
|
||||||
|
str)
|
||||||
'face (cond ((eq state 'needs-update)
|
'face (cond ((eq state 'needs-update)
|
||||||
'doom-modeline-warning)
|
'doom-modeline-warning)
|
||||||
((memq state '(removed conflict unregistered))
|
((memq state '(removed conflict unregistered))
|
||||||
|
|
Loading…
Reference in a new issue