Function: doom-modeline-segment--workspace-name

doom-modeline-segment--workspace-name is a natively compiled function defined in doom-modeline-segments.el.

Signature

(doom-modeline-segment--workspace-name)

Documentation

The current workspace name.

Requires eyebrowse-mode to be enabled or tab-bar-mode(var)/tab-bar-mode(fun) tabs to be created.

Source Code

;; Defined in /nix/store/1lcicrdd2r4b8rkc91nnn74ymk1jl6yd-emacs-packages-deps/share/emacs/site-lisp/elpa/doom-modeline-20260928.1632/doom-modeline-segments.el
;;
;; Workspace
;;

(doom-modeline-def-segment workspace-name
  "The current workspace name.
Requires `eyebrowse-mode' to be enabled or `tab-bar-mode' tabs to be created."
  (when (and doom-modeline-workspace-name
             (not doom-modeline--limited-width-p))
    (when-let*
        ((name (cond
                ((and (bound-and-true-p eyebrowse-mode)
                      (length> (eyebrowse--get 'window-configs) 1))
                 (setq mode-line-misc-info
                       (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 (length> tag 0) tag (int-to-string num))))
                ((and (fboundp 'tab-bar-mode)
                      (length> (frame-parameter nil 'tabs) 1))
                 (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))))))
         (keymap (let ((map (make-sparse-keymap)))
                   (cond ((and (bound-and-true-p eyebrowse-mode)
                               (length> (eyebrowse--get 'window-configs) 1))
                          (define-key map [mode-line mouse-1] #'eyebrowse-switch-to-window-config)
                          (define-key map [mode-line mouse-2]
                            (lambda ()
                              (interactive)
                              (describe-function 'eyebrowse-mode))))
                         ((and (fboundp 'tab-bar-mode)
                               (length> (frame-parameter nil 'tabs) 1))
                          (define-key map [mode-line mouse-1] #'tab-bar-switch-to-tab)
                          (define-key map [mode-line mouse-2]
                            (lambda ()
                              (interactive)
                              (describe-function 'tab-bar-mode)))))
                   map)))
      (propertize (format " %s " name)
                  'face (doom-modeline-face 'doom-modeline-workspace-name)
                  'mouse-face 'mode-line-highlight
                  'help-echo "mouse-1: Switch workspace
mouse-2: Show help for minor mode"
                  'local-map keymap))))