I'd like to use a single function (and later keybind it to a single key) that would do the following:
- if treemacs is visible in the frame, focus to its window;
- if not, call
treemacs
.
I took a look at window-buffer
and get-buffer-window
, however it's not clear how would I utilize those functions: I don't have a buffer in a variable to start with, and programmatically predicting a treemacs buffer name kinda seems like an non-trivial task (buffer-name
gives me something like " *Treemacs-Scoped-Buffer-#<framec *scratch* (projectile-project) - GNU Emacs at HOST 0x555ed35d4cc8>*"
).
Do I have to loop through all the visible windows, get displayed buffer names and match them against " *Treemacs-Scoped-Buffer" instead? Is there a better way, say a treemacs specific treemacs-visible-p
that would tell me the info I need? Or do I approach the problem incorrectly?