alphapapa / ement.el

A Matrix client for GNU Emacs
GNU General Public License v3.0
476 stars 44 forks source link

Some way of restoring rooms and window-configs upon reconnection #178

Open phil-s opened 1 year ago

phil-s commented 1 year ago

One of the best things about having a Matrix client in Emacs is being able to have split windows and tab-bar-mode window configs of multiple chat rooms.

At present, ement-disconnect deletes all of the room buffers, and ement-connect has no idea about re-populating the window configurations which were left behind.

Initially I was thinking that some kind of desktop.el integration would be great, but that mostly only affects things when killing and restarting Emacs. That would still be super useful, but a way to restore the session windows after disconnecting and reconnecting without restarting Emacs would seem even better (that being something I'll need to do periodically on account of https://github.com/alphapapa/ement.el/issues/173 for example).

I have noticed this:

Room buffers and the room-list buffer can be bookmarked in Emacs, i.e. using C-x r m. This is especially useful with Burly: you can arrange an Emacs frame with several room buffers displayed at once, use burly-bookmark-windows to bookmark the layout, and then you can restore that layout and all of the room buffers by opening the bookmark, rather than having to manually arrange them every time you start Emacs or change the window configuration.

I gave that a try, but (a) ran into https://github.com/alphapapa/burly.el/issues/28 so something which wasn't brittle in that manner would be ideal; and (b) found that burly-bookmark-frames didn't seem to account for tab-bar-mode window configs, which is what I've used heavily for organising different sets of Matrix chat rooms.

This does feel a bit like asking to re-invent desktop.el... but I wonder whether desktop support could be added, and then something layered on top to allow ement to write sessions to a separate desktop file?

I'm going to post this as-is for now, as my browser wants me to restart it...

alphapapa commented 1 year ago

AFAIK this is already completely solved by Burly. I use it every time I connect to open a frame like this:

ement

I don't want to reimplement what Burly does into Ement itself.

(a) ran into https://github.com/alphapapa/burly.el/issues/28 so something which wasn't brittle in that manner would be ideal;

If you are encountering that issue with Burly, please chime in there and help us fix it.

found that burly-bookmark-frames didn't seem to account for tab-bar-mode window configs, which is what I've used heavily for organising different sets of Matrix chat rooms.

I use tab-bar-mode with burly-tabs-mode and burly-bookmark-windows. There may be an issue with burly-bookmark-frames and tab-bar-mode because tab-bar-mode tabs are much like, if not essentially, frames, being a window configuration. I haven't fully explored how burly-bookmark-frames interacts with tab-bar-mode tabs, because it predates tab-bar-mode and I don't use burly-bookmark-frames much, if at all. So if you're finding issues there, please file a bug report on Burly so it can be fixed.

alphapapa commented 10 months ago

I've added this to my config and it works well for me:

(add-hook 'ement-after-initial-sync-hook
            (defun ap/ement-open-burly-bookmark (session)
              "Open Burly bookmark for Ement session."
              (bookmark-maybe-load-default-file)
              (pcase (ement-user-id (ement-session-user session))
                ("@alphapapa:matrix.org" (bookmark-jump "Burly: @alphapapa:matrix.org (Ement)")))))
alphapapa commented 9 months ago

See also the new commands in https://github.com/alphapapa/bufler.el, bufler-workspace-save, bufler-workspace-open, bufler-workspace-reset.