Subject: Re: bug#58909: 29.0.50; [WIP PATCH] Deleting the last frame of an emacsclient doesn't ask to save

From: Jim Porter <[email-masked]>
Date: Mon, 31 Oct 2022 10:36:57 -0700

On 10/31/2022 5:44 AM, Eli Zaretskii wrote:
> I'm uneasy with this incompatible behavior change.  I can think of
> some legitimate use cases where "C-x 5 0" should not prompt, e.g., if
> the user intends to keep editing the file, and no application is
> waiting for the client to finish.  Why break such flows?

Maybe we should add an option like 
'server-save-before-deleting-last-frame', in case users prefer the old 
behavior? I had originally planned to add an option like this for the 
same reason you mention, but I didn't want to be too aggressive with 
adding extra options if they aren't really needed. Since you mentioned 
it too though, I think this should at least have an option.

Alternately, we could add a keybinding for 'server-edit-abort'. Then 
users could easily use that command to support this flow. That has the 
benefit that it's a command which is explicitly for saying, "I'm done 
with this file and don't want to save it," though it does break users' 
muscle memory.

Still another possibility would be to prompt only when closing a frame 
by clicking the "X" on the frame's title bar. When using a 
non-client/server Emacs, doing this prompts the user to save when 
closing the last frame. ('C-x 5 0' in this case would just error out, 
since it refuses to delete the last frame.) That's because clicking the 
X calls 'handle-delete-frame' which calls 'save-buffers-kill-emacs' in 
that case. Then clicking the "X" would behave similarly when deleting 
the last frame of a client and deleting the last frame overall.

I think I prefer one of the first two though.

> Deleting a frame does no harm as long as Emacs is still up and running
> after that, so IMO forcing the user to answer such a prompt could be
> an annoyance.

I think it does about the same amount of harm as pressing 'C-x C-c' in 
an emacs client. Since my patch only affects the case when there's a 
single frame for the client, both 'C-x C-c' and 'C-x 5 0' would do the 
same thing (aside from prompting): they close the current frame and 
terminate the client connection.