ui/doom-modeline: optimize vcs segment (experimental)
This commit is contained in:
parent
fbce2388ab
commit
9ae99deb65
1 changed files with 40 additions and 34 deletions
|
@ -376,8 +376,9 @@ directory, the file name, and its state (modified, read-only or non-existent)."
|
|||
;; vcs
|
||||
;;
|
||||
|
||||
(def-modeline-segment! vcs
|
||||
"Displays the current branch, colored based on its state."
|
||||
(defvar +doom-modeline--vcs nil)
|
||||
(defun +doom-modeline--update-vcs ()
|
||||
(setq +doom-modeline--vcs
|
||||
(when (and vc-mode buffer-file-name)
|
||||
(let* ((backend (vc-backend buffer-file-name))
|
||||
(state (vc-state buffer-file-name backend)))
|
||||
|
@ -409,7 +410,12 @@ directory, the file name, and its state (modified, read-only or non-existent)."
|
|||
" "
|
||||
(propertize (substring vc-mode (+ (if (eq backend 'Hg) 2 3) 2))
|
||||
'face (if active face))
|
||||
" ")))))
|
||||
" "))))))
|
||||
(add-hook 'after-save-hook #'+doom-modeline--update-vcs)
|
||||
(add-hook 'find-file-hook #'+doom-modeline--update-vcs t)
|
||||
|
||||
(def-modeline-var! vcs +doom-modeline--vcs
|
||||
"Displays the current branch, colored based on its state.")
|
||||
|
||||
|
||||
;;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue