From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jim Porter Newsgroups: gmane.emacs.bugs Subject: bug#51993: 29.0.50; [PATCH] Killing emacsclient terminal with `server-stop-automatically' doesn't prompt to save files Date: Fri, 21 Oct 2022 20:46:47 -0700 Message-ID: <2738f071-c87f-72cf-226f-6e8597cb07a8@gmail.com> References: <9e47c871-a2c3-d764-bec9-d87abf3efe83@gmail.com> <79a53ecc-dbfc-d088-d80d-96f349be794a@gmail.com> <834k7vw2vb.fsf@gnu.org> <87czc4tosz.fsf@gnus.org> <83lepoi58p.fsf@gnu.org> <83y1tbxbbt.fsf@gnu.org> <83h6zxwujo.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="35980"; mail-complaints-to="usenet@ciao.gmane.io" Cc: larsi@gnus.org, 51993@debbugs.gnu.org, gregory@heytings.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Oct 22 07:07:44 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1om6jY-0009AM-E5 for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 22 Oct 2022 07:07:44 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1om5TV-0008CU-Q8; Fri, 21 Oct 2022 23:47:05 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1om5TT-0008CL-CG for bug-gnu-emacs@gnu.org; Fri, 21 Oct 2022 23:47:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1om5TS-0006oc-8m for bug-gnu-emacs@gnu.org; Fri, 21 Oct 2022 23:47:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1om5TR-00026D-Qh for bug-gnu-emacs@gnu.org; Fri, 21 Oct 2022 23:47:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Jim Porter Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 22 Oct 2022 03:47:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 51993 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 51993-submit@debbugs.gnu.org id=B51993.16664104178057 (code B ref 51993); Sat, 22 Oct 2022 03:47:01 +0000 Original-Received: (at 51993) by debbugs.gnu.org; 22 Oct 2022 03:46:57 +0000 Original-Received: from localhost ([127.0.0.1]:39461 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1om5TM-00025t-Ge for submit@debbugs.gnu.org; Fri, 21 Oct 2022 23:46:56 -0400 Original-Received: from mail-pl1-f179.google.com ([209.85.214.179]:46000) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1om5TL-00025g-47 for 51993@debbugs.gnu.org; Fri, 21 Oct 2022 23:46:55 -0400 Original-Received: by mail-pl1-f179.google.com with SMTP id u6so3984634plq.12 for <51993@debbugs.gnu.org>; Fri, 21 Oct 2022 20:46:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:mime-version:date:message-id:from:to:cc :subject:date:message-id:reply-to; bh=gJNAisIB/jayPvQPhwAmq7cvhohCseRa3oJHe7WYw9M=; b=Tm7txLzwi49NYKEnwpXy23IeOrcqOmx9LU8fRmJmnU3QZ1SMWHjF0/EozP3isSmUzY zDAZvQLNt5Psx8JCBI/Uw84GNHeIriBPzDzY6VLZ5SQr3qbS6S2o55hih7bcdzmN8Ln9 HZlVEHnZzW9O4aA6aorNmPT6XSDAIMMc6grdqaQQapqsBlXCp65Ap8D7800aja2GXEww 3Z9ZwflIJyHIAOzNwSs8pS9T2TjL9kna9Bd3huoulRh0XmA9KAxdV2Ap/5EIgV+iV0u5 yqIb2vgsFe9wfLra9CdKczHTYXkA/DcuLKmTlxae667DyQVaMCCqD77UYeYPmlsqkW/O pLlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=gJNAisIB/jayPvQPhwAmq7cvhohCseRa3oJHe7WYw9M=; b=6DozG1P4I0VD0lnVcdrhXjh1SMYcDg2EQWvnrRejZVX5vUqiOZyybGdAzoSWRnPs1c K1UyheG2Eonxz98cs9lIQxuhw+BeRVRmHqyd7Ar/5eNq2mK5HC66Q2gtJT5WqKKKiVN1 iV05gQ5LPUohct5cGUwRsuXLUKBcl8kX3Du3iwQXOliAPRubyq7cBL5xbWLCeJ1yPCRn Q4xfwCDbUwdlcPus4BqKpqOtmQ5vQ8kzFl0MLlw7H1ADJPiTB4Neu+jtPFW6wqDgEBgY YJnT+JfQATJBnmB83xJ3oYCCLh5/kCQAcZ/3aK5+Jc8fl5OXLf/JBYwCXJI3jMj0yhQR raJg== X-Gm-Message-State: ACrzQf2ZF9SBVasG6uT/s2l74ODd8aogNxW6sZFJtHAJJkDICatd3GJh 0R546eTpasjVjAr6yZLTtgc= X-Google-Smtp-Source: AMsMyM7ZhxEJH5bW+j9WBMIKl9tcXtJ+TF7FxkR8DQt/2OQFwJo/YzYkUUX6/X7p7L4RX2eIR8ZQMQ== X-Received: by 2002:a17:90b:4a4d:b0:20d:4dc7:fa72 with SMTP id lb13-20020a17090b4a4d00b0020d4dc7fa72mr25152448pjb.86.1666410409072; Fri, 21 Oct 2022 20:46:49 -0700 (PDT) Original-Received: from [192.168.1.2] (cpe-76-168-148-233.socal.res.rr.com. [76.168.148.233]) by smtp.googlemail.com with ESMTPSA id m17-20020a656a11000000b0045751ef6423sm13969547pgu.87.2022.10.21.20.46.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 21 Oct 2022 20:46:47 -0700 (PDT) Content-Language: en-US In-Reply-To: <83h6zxwujo.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: "bug-gnu-emacs" Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:246020 Archived-At: On 10/20/2022 11:38 PM, Eli Zaretskii wrote: >> Date: Thu, 20 Oct 2022 22:51:42 -0700 >> Cc: larsi@gnus.org, 51993@debbugs.gnu.org, gregory@heytings.org >> From: Jim Porter >> >>>> b) if this *is* the last client, prompt the user to save everything >>>> (as with 'save-buffers-kill-emacs'), and then delete the client + kill >>>> the Emacs daemon. >>> >>> You mean, in b), instead of just deleting the frame and leaving the >>> daemon run, you want to shut down Emacs in its entirety, as if the >>> user invoked kill-emacs? I'm okay with that as an optional behavior, >>> although I myself won't use it, as it's too dangerous. >> >> Almost. I'd like it to be as if the user invoked >> 'save-buffers-kill-emacs'; that is, before killing Emacs, prompt the >> user about everything[1] that might be lost by killing Emacs. > > That should already happen, if you just call save-buffers-kill-emacs > in that case, right? Yeah. My expectation is that I can type 'C-x C-c' (or 'M-x save-buffers-kill-terminal') to kill a client, and if it's the last client, instead kill Emacs entirely (like 'M-x save-buffers-kill-emacs'). So roughly speaking, the change would be that you can set 'save-buffer-kill-terminal' to work like 'save-buffer-kill-emacs' when there's only 1 client left. >> This already exists as an option -- (server-stop-automatically >> 'delete-frame)[2], but I also find the current behavior too dangerous. >> My original message outlines one of the problems with the current >> implementation: it changes the behavior of (a) in my description above. >> >>> $ emacs -Q --daemon >>> $ emacsclient -a "" -c foo.txt >>> $ emacsclient -a "" -c bar.txt >>> >>> ;; In the first client frame: >>> foobar ;; Insert some text >>> C-x C-c >>> ;; Emacs prompts "Save file /path/to/foo.txt?..." >>> >>> Now try the above, but call `(server-stop-automatically 'delete-frame)' first (or replace `delete-frame' with `kill-terminal'; it doesn't matter). In this case, Emacs doesn't prompt to save the file. > > I'm not sure I see the direct relevance, and I don't think I see a bug > in the above behavior. I'm probably missing something, but what? The issue in the quote above is that if you enable automatic server shutdown in Emacs 29, it changes the behavior of exiting an emacsclient even when it wouldn't stop the server (i.e. when there are other active clients). That's surprising to me, I wouldn't expect that setting to affect cases when it decides *not* to kill the Emacs daemon. (This is relevant to the previous discussion since fixing this would get Emacs's automatic server shutdown - aka killing the daemon - close to the way I described there. Gregory mentioned[1] that the current behavior is intended, although we've had some difficulty coming to an agreement on how all this should work. Hence why I thought a hook might help here: if there are strong opinions in various directions, maybe a simple option isn't enough. Or maybe this is a case where you and/or Lars would be in a better position to make a final decision...) [1] https://debbugs.gnu.org/cgi/bugreport.cgi?bug=51993