Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display perspective in frame title #192

Open
sellout opened this issue Oct 18, 2022 · 7 comments
Open

Display perspective in frame title #192

sellout opened this issue Oct 18, 2022 · 7 comments

Comments

@sellout
Copy link

sellout commented Oct 18, 2022

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
Copy link
Author

sellout commented Oct 18, 2022

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
Copy link
Author

sellout commented Oct 18, 2022

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 …

@cmm
Copy link

cmm commented Oct 29, 2023

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)

@sellout
Copy link
Author

sellout commented Oct 29, 2023

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.

@gcv
Copy link
Collaborator

gcv commented Oct 29, 2023

@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.

@sellout
Copy link
Author

sellout commented Oct 30, 2023

@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.

@cmm
Copy link

cmm commented Oct 30, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants