0

A very annoying issue with desktop-save and desktop-read that I'm encountering at the moment:

  • I'm starting Emacs in daemon-mode, and then open a client frame. I do desktop-read and my saved desktop opens with the 10 or so frames I had saved.

  • When I go to one of the frames with a buffer I'm no longer interested in, and do C-x C-c, I end up not just closing that particular frame, but all 10 or so of the frames that were open.

  • The Emacs daemon is still running, and opening another client frame shows that the buffers haven't been killed, so nothing has been lost per se - it's just that the arrangement of all the frames I had is just ruined.

Any idea how to stop this behaviour (i.e. being able to just kill one frame from the saved configuration)?

I should add that I have also been using the minimal setup for desktop.el as shown in the EmacsWiki, but I think (but am not sure) that the problem is independent of this.

I have also played around with these settings

  (setq desktop-restore-frames t)
  (setq desktop-restore-in-current-display nil)
  (setq desktop-restore-forces-onscreen nil)

but the issue persists.

EDIT

Made a bug report but the response seems to be that this is expected behavior, and instead of C-x C-c one should use C-x 5 0 to kill frames.

See also this answer to a different question on closing emacsclient. It cites the info as follows

   The new graphical or text terminal frames created by the ‘-c’ or ‘-t’
options are considered “client frames”.  Any new frame that you create
from a client frame is also considered a client frame.  If you type ‘C-x
C-c’ (‘save-buffers-kill-terminal’) in a client frame, that command does
not kill the Emacs session as it normally does (*note Exiting::).
Instead, Emacs deletes the client frame; furthermore, if the client
frame has an ‘emacsclient’ waiting to regain control (i.e., if you did
not supply the ‘-n’ option), Emacs deletes all other frames of the same
client, and marks the client’s server buffers as finished, as though you
had typed ‘C-x #’ in all of them.  If it so happens that there are no
remaining frames after the client frame(s) are deleted, the Emacs
session exits.

   As an exception, when Emacs is started as a daemon, all frames are
considered client frames, and ‘C-x C-c’ never kills Emacs.  To kill a
daemon session, type ‘M-x kill-emacs’.

As a test, I started a normal GUI instance of Emacs -- i.e. not in daemon-mode -- and then used desktop-read to load the saved configuration of frames from before. Now doing C-x C-c kills the Emacs instance, after closing all the frames.

So to conclude I think the behavior outlined in my questions is just the way Emacs works, in particular with regards to using daemon-mode. Perhaps remapping C-x 5 0 or delete-frame to something more convenient would be the best thing to do.

nonreligious
  • 473
  • 2
  • 14
  • Sounds awful. Also sounds like there might be a bug. Consider using `M-x report-emacs-bug` - the Emacs devs will let you know if they think there's a bug there somewhere, or they might suggest a workaround. – Drew Mar 09 '22 at 01:41
  • @Drew I'm happy to report a bug, but would like to make sure that it isn't just me having this issue (although I have checked this on two different systems). Have you been able to replicate this? – nonreligious Mar 09 '22 at 18:03
  • I'm not trying to replicate it; sorry. – Drew Mar 09 '22 at 19:11

0 Answers0