deltille · 2022-11-15 17:24
I'm asking because now that I'm giving EXWM another spin, this has become more immediately relevant in my day-to-day. But this is functionality I've vaguely wanted in emacs without EXWM for a while anyway, so it's not EXWM-*specific*.
I do a few things that would really benefit from me being able to just run a single command and have a specific window layout set up - visit this file here, this one down here, [exwm-specific] "run this command and position the resulting window here", etc. etc.
For a more concrete example: take "scheduling doctor's appointments." Inevitably I need:
* 1) a firefox window for a map,
* 2) a second firefox window for my voip webapp,
* 3) pavucontrol or the like *available* (ie. on a tab, perhaps) in case I need to mess with my audio setup,
* 4) an emacs buffer open to 'call notes',
* 5) another emacs buffer open to my 'address book' for doctors, and finally,
* 6) a scratch buffer off in the corner.
(And, ideally, for all windows involved to resist me absentmindedly trying to change them to different buffers. I've heard mention of having a window 'dedicated' to a buffer in service to this idea.)
Would be much, much less tedious to just have [sane tooling for] one function that sets this up for me in the desired layout, or a system that lets me 'save' a configuration, especially if that system understood EXWM or generally-speaking the concept of needing to run a specific shell command and wait in order get the desired buffer.
I know this is hardly a new problem and the gamut of *potential* solutions is overwhelming me a bit; I've avoided getting very deep into emacs' window logic, and instead relied on spamming separate frames, which is a habit I'd like to get out of. What I have researched tends to either solve only one part of my problem (eg. desktop saving), or imposes an overarcing model that I'm ambivalent about (eg. perspectives, *also* desktop saving to a degree).
So, what approaches exist to this kind of problem that you use/would personally consider using? Why?
gammarray · 2022-11-15 18:27
In the past I have done similar things with some hacky elisp that makes use of timers and EXWM workspace switch commands to create layouts across multiple workspaces for me. It’s not hard to do, but also not a simple push button solution. Heh, of course once you’ve scripted it out, you can assign the elisp to a keyboard shortcut.
deltille · 2022-11-15 19:03
'Push button' might be a *bit* misleading phrasing in terms of the level of ease I expect-- it *is* still emacs after all. (Plus in EXWM's case, it's still X11, and I know the relationship between process and window in X11 is *tenuous.*) I'm perfectly happy writing/tweaking some bespoke elisp if it comes down to it. Do share if you have it handy :)
7890yuiop · 2022-11-15 22:01
The in-built `tab-bar-mode` makes tabs (aka "buttons") for window configurations. Does that solve your problem?
MitchellMarquez42 · 2022-11-15 22:26
One thing you could use as a starting point is Keyboard Macros. https://www.masteringemacs.org/article/keyboard-macros-are-misunderstood
Tl;dr:
`C-x (`
<arrange windows/buffers however you want using keyboard>
`C-x )`
`C-x C-k n` <name for macro>
Now you can paste it into your config with `M-x insert-kbd-macro` and debug as usual from there.
EDIT: fixed capitalized letters in link.
deltille · 2022-11-16 02:18
This has got me about 1/3 of the way there! Been futzing with it this entire afternoon.
deltille · 2022-11-16 02:19
I didn't even know this functionality was here! Definitely a tool I want to have for repetition of setups before I actually codify them if nothing else. thanks!
gammarray · 2022-11-17 02:32
This is a pretty basic example from my config:
(defun comms-mode()
(interactive)
(run-with-idle-timer 0.15 nil (lambda() (interactive) (exwm-workspace-switch 3)))
(run-with-idle-timer 0.5 nil (lambda() (interactive)
(start-process-shell-command "GMail" nil "firefox --new-window https://mail.google.com/mail/u/0/")))
(run-with-idle-timer 1 nil (lambda() (interactive)
(split-window-below)
(run-with-idle-timer 0.2 nil (lambda() (windmove-down)(start-process-shell-command "HelpScout" nil "firefox --new-window https://secure.helpscout.net/"))))))
deltille · 2022-11-17 16:25
Thanks. This is looking increasingly like the right approach for me; tab-bar-mode definitely seems to be the right solution for the 'saved layout' part of it.
(It (tab-bar-mode) handles 'sharing' of X windows between layouts better than EXWM workspaces does... Though, AFAICT, the 'workspace' idea in EXWM seems to consider 'completely separated spaces with different buffer lists' the default and any other use an aberration, and my use is definitely aberrant from that. I tend to prefer the DWM approach where windows have 'tags' and 'workspaces' just collect said tags.)
Hopefully this description helps someone else as well :)