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 for 29.1] Killing emacsclient terminal with `server-stop-automatically' doesn't prompt to save files Date: Thu, 1 Dec 2022 17:09:24 -0800 Message-ID: <8e62e7aa-7050-6b35-9128-79517efa4557@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> <2738f071-c87f-72cf-226f-6e8597cb07a8@gmail.com> <83a65ouz0e.fsf@gnu.org> <83lenrghhg.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------mz2pxLnUwNZjD3580PwCUiid" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20297"; 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 Fri Dec 02 02:10:25 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 1p0uZN-00052M-2J for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 02 Dec 2022 02:10:25 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p0uZ4-0003N4-Rl; Thu, 01 Dec 2022 20:10:06 -0500 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 1p0uZ1-0003Mj-7f for bug-gnu-emacs@gnu.org; Thu, 01 Dec 2022 20:10:03 -0500 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 1p0uYz-0003YP-St for bug-gnu-emacs@gnu.org; Thu, 01 Dec 2022 20:10:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p0uYz-00047X-Kv for bug-gnu-emacs@gnu.org; Thu, 01 Dec 2022 20:10:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Jim Porter Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 02 Dec 2022 01:10: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.166994337715827 (code B ref 51993); Fri, 02 Dec 2022 01:10:01 +0000 Original-Received: (at 51993) by debbugs.gnu.org; 2 Dec 2022 01:09:37 +0000 Original-Received: from localhost ([127.0.0.1]:43021 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p0uYa-00047D-EU for submit@debbugs.gnu.org; Thu, 01 Dec 2022 20:09:36 -0500 Original-Received: from mail-pj1-f45.google.com ([209.85.216.45]:35425) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p0uYX-000476-6u for 51993@debbugs.gnu.org; Thu, 01 Dec 2022 20:09:34 -0500 Original-Received: by mail-pj1-f45.google.com with SMTP id w4-20020a17090ac98400b002186f5d7a4cso6919243pjt.0 for <51993@debbugs.gnu.org>; Thu, 01 Dec 2022 17:09:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=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=Mut6/v0WZX6H6vjNNb5qbPbGk1aHslPEn9cLqviA+bI=; b=Z5vt0AR0OP5AIdheQDhxLmvr2fo3zpYofjJtVoa6QEKGYfMBKw7m4jlRd9CzUJlIt3 pYOIP2w4HSf6OkydCC+DXWcP5URP2mYbrRXWURBJi87GgJ3bgv2ttt3Nwxux9nHuR9I2 +fHwfJwmOwotAoDC175EGl4aWuFIQ4seR28iZg2eOugFOcXBWj2TsHsLa5gZpy1VaK9H FhIttujJc9pWiCMnI6ydyJdwOxty17W8mbUNucE/iGeBRdGWiZDeBWywYuYhWep2XCIW IE/ZijVJSJjboAzYyTB/DaBDKu0ZsQPkYvLRR5w+SxiqvdD+2Cf9WDqhl+ieNQS1kv5v StdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=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=Mut6/v0WZX6H6vjNNb5qbPbGk1aHslPEn9cLqviA+bI=; b=AZ87ad/XsCtHvgH5/ip3ipXTIEgPefn1HOQ/xH+ytxelgpcn4/QKbwPep8wLWRcJ25 SfIj05JHRDmgTAJTcPmkVtjLF5ylAa1Tag6dzAF1rZeNDpIROOsATSY/Kz/ugAzTQBaI DmlufhAX+i012u/RUMY8Bga09N8Xmwei3A3FXNim1C9LZFC12LtT733Q1hIcnYbhx1x5 AhpPfukLGBaTiEtbcMiQSSP6KjRl43xN5eCAJz8jHFgv9YyzkkJlwAmJ04YplKbg/yzi CpwfLDA1BS7sHuqYYCmk20p0Rsech2ZeHYLv+lU0I63iB8rYOyI1iynAxn5HpL4BruGd KOGg== X-Gm-Message-State: ANoB5pk5jMnUyy3Tb2D/s1LyqfJzRP3/brimT7pLjJbpfRNYm3Gebdp4 cdNkWHA3SLHkclxCo4AKB7Y= X-Google-Smtp-Source: AA0mqf5+F/ydVuvwV1eoCJS/oy8ftmNkM7lvFpsbcwpy2JUR+f/HVmrySz7iQ+pnr7kkRC0Z5DDQzA== X-Received: by 2002:a17:90b:ed1:b0:210:a844:217c with SMTP id gz17-20020a17090b0ed100b00210a844217cmr74733229pjb.150.1669943367166; Thu, 01 Dec 2022 17:09:27 -0800 (PST) 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 u2-20020a170902e80200b0018980f14940sm4273291plg.178.2022.12.01.17.09.25 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 01 Dec 2022 17:09:26 -0800 (PST) Content-Language: en-US In-Reply-To: <83lenrghhg.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: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:249683 Archived-At: This is a multi-part message in MIME format. --------------mz2pxLnUwNZjD3580PwCUiid Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 12/1/2022 9:29 AM, Eli Zaretskii wrote: >> Date: Mon, 28 Nov 2022 21:31:02 -0800 >> From: Jim Porter >> Cc: larsi@gnus.org, 51993@debbugs.gnu.org, gregory@heytings.org >> >>>>> 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. >>>> >>>> Sounds like a bug to me, because it contradicts what the doc string >>>> says. >>> >>> That's how it seems to me too. ... >> Ok, after quite a delay, here's a patch for this. Previously, the >> function 'server-stop-automatically--handle-delete-frame' responded to >> both 'C-x C-c' ('save-buffers-kill-terminal') and 'delete-frame', which >> made it more complex. I've moved the 'C-x C-c' case into >> 'server-save-buffers-kill-terminal', which simplifies >> 'server-stop-automatically--handle-delete-frame'. >> >> The updated 'server-save-buffers-kill-terminal' should now make sure >> that the new stop-automatically behavior only happens when there are no >> other client processes (or nowait frames). > > We want this on the release branch, right? Then please make it the minimal > change which fixes the immediate cause of the bug, and does nothing else: no > refactoring, no reshuffling of the code or making it nicer or less > complicated -- all that just makes the risk of new bugs higher and the job > of reviewing the patch harder. Thanks for taking a look. I believe we'd want this on the release branch. Here's the absolute minimum I could manage, although it doesn't quite fix everything that my previous patch does. In particular, when server-stop-automatically is set to 'kill-terminal' (or 'delete-frame'): * If you type 'C-x C-c' ('save-buffers-kill-terminal') in a nowait client frame, and there are still other (non-daemon) frames, nothing happens. You'd have to use 'C-x 5 0' ('delete-frame') instead. Fixing this would basically mean doing 90% of my original patch, so it's probably too risky. * If you type 'C-u C-x C-c', it doesn't silently save all the relevant buffers. That's because 'server-save-buffers-kill-terminal' doesn't forward the prefix arg to 'server-stop-automatically--handle-delete-frame'. That's a separate (but closely related) bug, so I didn't fix that either. In a followup message, I'll show the breakdown of my previous patch into smaller steps with some more detailed explanation of why I think it simplifies things enough to be worth making the change on the master branch. --------------mz2pxLnUwNZjD3580PwCUiid Content-Type: text/plain; charset=UTF-8; name="0001-Make-killing-a-non-last-client-work-the-same-no-matt.patch" Content-Disposition: attachment; filename*0="0001-Make-killing-a-non-last-client-work-the-same-no-matt.pa"; filename*1="tch" Content-Transfer-Encoding: base64 RnJvbSAxOThmOThiNDNkNWRkZTM0Nzc1MDEwYWM5ODdkMzFlOTA3NDUzODFmIE1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mKSkpCi0JCSAgKHNldC1mcmFtZS1wYXJhbWV0ZXIgZiAnY2xp ZW50IG5pbCkKLQkJICAobGV0ICgoc2VydmVyLXN0b3AtYXV0b21hdGljYWxseSBuaWwpKQot CQkgICAgKGRlbGV0ZS1mcmFtZSBmKSkpKQotCSAgICAgIChpZiAoY2RkciAoZnJhbWUtbGlz dCkpCi0JCSAgKGxldCAoKHNlcnZlci1zdG9wLWF1dG9tYXRpY2FsbHkgbmlsKSkKLQkJICAg IChkZWxldGUtZnJhbWUgZnJhbWUpCi0JCSAgICBuaWwpCi0JCXQpKQorICAgICAgICAgICAg KGxldCogKChwcm9jIChmcmFtZS1wYXJhbWV0ZXIgZnJhbWUgJ2NsaWVudCkpCisgICAgICAg ICAgICAgICAgICAgOzsgS2VlcCB0aGUgc2VydmVyIGFsaXZlIGlmLi4uCisgICAgICAgICAg ICAgICAgICAgKGtlZXAtc2VydmVyLWFsaXZlLXAKKyAgICAgICAgICAgICAgICAgICAgKG9y CisgICAgICAgICAgICAgICAgICAgICA7OyBhKSB0aGVyZSBhcmUgYW55IG90aGVyIGNsaWVu dHMsIG9yLi4uCisgICAgICAgICAgICAgICAgICAgICAobGVuZ3RoPiBzZXJ2ZXItY2xpZW50 cyAxKQorICAgICAgICAgICAgICAgICAgICAgOzsgYikgdGhlcmUgYXJlIGFueSBmcmFtZXMg bm90IG93bmVkIGJ5IHRoaXMKKyAgICAgICAgICAgICAgICAgICAgIDs7IGNsaWVudC4KKyAg ICAgICAgICAgICAgICAgICAgIChzZXEtc29tZQorICAgICAgICAgICAgICAgICAgICAgIChs YW1iZGEgKGZyYW1lKQorICAgICAgICAgICAgICAgICAgICAgICAgKHdoZW4tbGV0ICgocCAo ZnJhbWUtcGFyYW1ldGVyIGZyYW1lICdjbGllbnQpKSkKKyAgICAgICAgICAgICAgICAgICAg ICAgICAgKG5vdCAoZXEgcHJvYyBwKSkpKQorICAgICAgICAgICAgICAgICAgICAgIChmcmFt ZS1saXN0KSkpKSkKKyAgICAgICAgICAgICAgKHdoZW4ga2VlcC1zZXJ2ZXItYWxpdmUtcAor ICAgICAgICAgICAgICAgIDs7IElmIHdlIHdhbnQgdG8ga2VlcCB0aGUgc2VydmVyIGFsaXZl LCBkb24ndCBraWxsCisgICAgICAgICAgICAgICAgOzsgRW1hY3MuICBJbnN0ZWFkLCBqdXN0 IGNhbGwgYHNhdmUtc29tZS1idWZmZXJzJyBhbmQKKyAgICAgICAgICAgICAgICA7OyBkZWxl dGUgdGhlIGNsaWVudCwgYXMgaW4KKyAgICAgICAgICAgICAgICA7OyBgc2VydmVyLXNhdmUt YnVmZmVycy1raWxsLXRlcm1pbmFsJyBhYm92ZS4KKyAgICAgICAgICAgICAgICAobGV0ICgo YnVmZmVycyAocHJvY2Vzcy1nZXQgcHJvYyAnYnVmZmVycykpKQorCSAgICAgICAgICAoc2F2 ZS1zb21lLWJ1ZmZlcnMKKyAgICAgICAgICAgICAgICAgICBuaWwgKGlmIGJ1ZmZlcnMKKyAg ICAgICAgICAgICAgICAgICAgICAgICAgIChsYW1iZGEgKCkgKG1lbXEgKGN1cnJlbnQtYnVm ZmVyKSBidWZmZXJzKSkpKQorCSAgICAgICAgICAoc2VydmVyLWRlbGV0ZS1jbGllbnQgcHJv YykpKQorICAgICAgICAgICAgICA7OyBUZWxsIHRoZSBvdXRlciBgaWYnIGJsb2NrIHdoZXRo ZXIgd2Ugd2FudCB0byBraWxsCisgICAgICAgICAgICAgIDs7IEVtYWNzLgorICAgICAgICAg ICAgICAobm90IGtlZXAtc2VydmVyLWFsaXZlLXApKQogCSAgKG51bGwgKGNkZHIgKGZyYW1l LWxpc3QpKSkpCiAJKGxldCAoKHNlcnZlci1zdG9wLWF1dG9tYXRpY2FsbHkgbmlsKSkKIAkg IChzYXZlLWJ1ZmZlcnMta2lsbC1lbWFjcykKLS0gCjIuMjUuMQoK --------------mz2pxLnUwNZjD3580PwCUiid--