mirror of
https://github.com/doomemacs/doomemacs
synced 2025-08-03 12:27:26 -05:00
ui/doom-modeline: optimize vcs segment (experimental)
This commit is contained in:
@ -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.")
|
||||
|
||||
|
||||
;;
|
||||
|
Reference in New Issue
Block a user