wasamasa / eyebrowse

A simple-minded way of managing window configs in emacs
GNU General Public License v3.0
437 stars 24 forks source link

[Feature] Display workspace using frame title (sample code inside) #76

Closed tuhdo closed 6 years ago

tuhdo commented 6 years ago

It would be great if eyebrowse can display the workspace info on the frame title with the current buffer name. Here is my workaround based on the limited understanding of eyebrowse source code:

(defun tuhdo/eyebrowse-frame-line-indicator (&optional update-buffer-list)
  "Return a string representation of the window configurations."
  (let* ((separator " | ")
         (current-slot (eyebrowse--get 'current-slot))
         (window-configs (eyebrowse--get 'window-configs)))
    ;; (message "windows configs: %s" window-configs)
    (mapconcat
     (lambda (window-config)
       (let* ((slot (car window-config))
              (left-selector (if (= slot current-slot) "< " ""))
              (right-selector (if (= slot current-slot) " >" ""))
              (caption (if (and update-buffer-list (= slot current-slot))
                           (buffer-name (current-buffer))
                         (cadr (assoc 'buffer (cadr window-config))))))
         (concat left-selector
                 caption
                 right-selector)))
     window-configs separator)))

(defun tuhdo/eyebrowse-set-frame-indicator ()
  (set-frame-name (tuhdo/eyebrowse-frame-line-indicator)))

(defun tuhdo/eyebrowse-set-frame-indicator-buffer-update ()
  (set-frame-name (tuhdo/eyebrowse-frame-line-indicator t)))

 (add-hook 'buffer-list-update-hook 'tuhdo/eyebrowse-set-frame-indicator-buffer-update)
 (add-hook 'eyebrowse-post-window-switch-hook 'tuhdo/eyebrowse-set-frame-indicator)
(setq eyebrowse-new-workspace t
        eyebrowse-mode-line-style nil)

After running the code, workspace information should display on the frame title.

wasamasa commented 6 years ago

Sorry, but no. This is a prime example of something best left to users who need something more intrusive than a mode line indicator.

tuhdo commented 6 years ago

How about making it another option? By default, mode line is used. However, I think displaying the workspace in the mode line is useless because most of the time I have 2 windows side by side, sometimes more. The mode line is then cannot display all the workspaces.

wasamasa commented 6 years ago

Hooking into buffer-list-update-hook makes this pretty much unacceptable.

tuhdo commented 6 years ago

Then, just leave that hooks out. The hook is to make eyebrowse update the workspace names whenever I change a buffer. Without hooking into it, the buffer names are updated only when I switch to another workspace.

Currently, eyebrowse uses tagged names, which make it unnecessary to hook into buffer-list-update-hook. Btw, it would be nice if eyebrowse can use the current buffer name as workspace name.