perspective-el icon indicating copy to clipboard operation
perspective-el copied to clipboard

Display perspective in frame title

Open sellout opened this issue 2 years ago • 7 comments

Since there is one (or merged) active perspective in a frame, displaying it in the title makes more sense than in the mode-line or header. So, suggesting another possible value for persp-show-modestring: 'frame-title.

There’s no global-frame-title to append it to, but searching frame-title-format for "%b" and adding an entry just before it, (like ((:edit (persp-mode-line)) "%b") in the simplest case) might do it.

As an added bonus, when I go to share a window with Google Meet, it can be hard to find the right window to select (they are all just random buffer names), so having the perspective for that frame in the title would be very helpful.

sellout avatar Oct 18 '22 20:10 sellout

Ah, since it doesn’t propertize text in the title, you probably also want to always treat persp-modestring-short as t if persp-show-modestring is 'frame-title. I use the short form anyway, so I didn’t notice initially.

sellout avatar Oct 18 '22 20:10 sellout

Ok, my quick experiment is not so successful – it sets the title for all frames to whatever perspective the selected frame is in. But I’m sure there’s a way around that …

sellout avatar Oct 18 '22 20:10 sellout

FWIW this seems to work for me:

(setq frame-title-format '("%b" (:eval (when-let ((persp (frame-parameter nil 'persp--curr))) (format " [%s]" (persp-name persp))))))

(but of course relying on non-public things is not ideal)

cmm avatar Oct 29 '23 11:10 cmm

Thanks, @cmm, that looks like it works for me. I extracted it into a function:

(defun persp-frame-title ()
  (when-let ((persp (frame-parameter nil 'persp--curr)))
    (let ((open (nth 0 persp-modestring-dividers))
          (close (nth 1 persp-modestring-dividers)))
      (concat open persp close))))

(setq frame-title-format '((:eval (persp-frame-title)) " %b"))

It matches the existing rendering (e.g., using persp-modestring-dividers), but always treats it as the short modestring, since there’s no propertization in the frame title.

sellout avatar Oct 29 '23 17:10 sellout

@sellout: Have you tried using (persp-current-name) in place of (frame-parameter nil 'persp--curr)?

I would merge in a PR that added persp-frame-title and included documentation about how to use it.

gcv avatar Oct 29 '23 21:10 gcv

@sellout: Have you tried using (persp-current-name) in place of (frame-parameter nil 'persp--curr)?

I hadn’t. It looks like

(defun persp-frame-title ()
  (let ((open (nth 0 persp-modestring-dividers))
        (close (nth 1 persp-modestring-dividers)))
    (concat open (persp-current-name) close)))

works just as well.

I would merge in a PR that added persp-frame-title and included documentation about how to use it.

I think for a PR, adding (const :tag "Frame Title" frame-title) to persp-show-modestring would be the way to go. I’m happy to submit one (with @cmm tagged as co-author), unless @cmm would like to submit one themselves.

sellout avatar Oct 30 '23 04:10 sellout

@sellout happy to have helped (I guess, not really sure?), feel free to go ahead :)

cmm avatar Oct 30 '23 08:10 cmm