Add modeline segment for follow-mode (#489)

When follow-mode is enabled for a buffer, this will show a segment left
of buffer-info (which contains the file name) like "Follow M/N", where N
is the total number of follow windows for this buffer and M is the index
of the selected window.
This commit is contained in:
Robert Irelan 2021-11-11 00:34:52 -08:00 committed by GitHub
parent 6a312f7fe9
commit 36fed6d1a1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 1 deletions

View file

@ -2947,6 +2947,21 @@ mouse-3: Restart preview"
map)))
(doom-modeline-spc))))
;;
;; Follow mode
;;
(doom-modeline-def-segment follow
(when (bound-and-true-p follow-mode)
(let* ((windows (follow-all-followers))
(nwindows (length windows))
(nfollowing (- (length (memq (selected-window) windows))
1)))
(concat
(doom-modeline-spc)
(propertize (format "Follow %d/%d" (- nwindows nfollowing) nwindows)
'face 'doom-modeline-buffer-minor-mode)))))
(provide 'doom-modeline-segments)
;;; doom-modeline-segments.el ends here

View file

@ -90,7 +90,7 @@
;;
(doom-modeline-def-modeline 'main
'(bar workspace-name window-number modals matches buffer-info remote-host buffer-position word-count parrot selection-info)
'(bar workspace-name window-number modals matches follow buffer-info remote-host buffer-position word-count parrot selection-info)
'(objed-state misc-info persp-name battery grip irc mu4e gnus github debug repl lsp minor-modes input-method indent-info buffer-encoding major-mode process vcs checker))
(doom-modeline-def-modeline 'minimal