[Feature] Support tab-bar-mode in workspace-name segment.

Close #317.
This commit is contained in:
Vincent Zhang 2020-03-12 01:22:04 +08:00
parent 5bffef2568
commit 883370eb16

View file

@ -193,6 +193,8 @@
(declare-function symbol-overlay-get-list 'symbol-overlay)
(declare-function symbol-overlay-get-symbol 'symbol-overlay)
(declare-function symbol-overlay-rename 'symbol-overlay)
(declare-function tab-bar--current-tab 'tab-bar)
(declare-function tab-bar--current-tab-index 'tab-bar)
(declare-function tracking-next-buffer 'tracking)
(declare-function tracking-previous-buffer 'tracking)
(declare-function tracking-shorten 'tracking)
@ -1349,19 +1351,26 @@ one. The ignored buffers are excluded unless `aw-ignore-on' is nil."
(doom-modeline-def-segment workspace-name
"The current workspace name or number.
Requires `eyebrowse-mode' to be enabled."
(if (and (bound-and-true-p eyebrowse-mode)
(< 1 (length (eyebrowse--get 'window-configs))))
(let* ((num (eyebrowse--get 'current-slot))
(tag (when num (nth 2 (assoc num (eyebrowse--get 'window-configs)))))
(str (if (and tag (< 0 (length tag)))
tag
(when num (int-to-string num)))))
(assq-delete-all 'eyebrowse-mode mode-line-misc-info)
(propertize (format " %s " str) 'face
(if (doom-modeline--active)
'doom-modeline-buffer-major-mode
'mode-line-inactive)))))
Requires `eyebrowse-mode' or `tab-bar-mode' to be enabled."
(when-let
((name (cond
((and (bound-and-true-p eyebrowse-mode)
(< 1 (length (eyebrowse--get 'window-configs))))
(assq-delete-all 'eyebrowse-mode mode-line-misc-info)
(when-let*
((num (eyebrowse--get 'current-slot))
(tag (nth 2 (assoc num (eyebrowse--get 'window-configs)))))
(if (< 0 (length tag)) tag (int-to-string num))))
((bound-and-true-p tab-bar-mode)
(let* ((current-tab (tab-bar--current-tab))
(tab-index (tab-bar--current-tab-index))
(explicit-name (alist-get 'explicit-name current-tab))
(tab-name (alist-get 'name current-tab)))
(if explicit-name tab-name (+ 1 tab-index)))))))
(propertize (format " %s " name) 'face
(if (doom-modeline--active)
'doom-modeline-buffer-major-mode
'mode-line-inactive))))
;;