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#59668: 29.0.50; [PATCH] Make 'server-stop-automatically' into a defcustom Date: Thu, 1 Dec 2022 10:33:57 -0800 Message-ID: <70013d69-1d9d-c268-fd9b-8b04c362aabc@gmail.com> References: <155f479d-3bae-c327-47a3-7b58daf912c0@gmail.com> <83mt87gih4.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="27019"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 59668@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Dec 01 19:35:28 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 1p0oPA-0006nB-7v for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 01 Dec 2022 19:35:28 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p0oOs-00046Q-OW; Thu, 01 Dec 2022 13:35:10 -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 1p0oOo-00041J-DM for bug-gnu-emacs@gnu.org; Thu, 01 Dec 2022 13:35:08 -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 1p0oOn-0000ms-Lb for bug-gnu-emacs@gnu.org; Thu, 01 Dec 2022 13:35:05 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p0oOk-0000TY-8h for bug-gnu-emacs@gnu.org; Thu, 01 Dec 2022 13:35:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Jim Porter Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 01 Dec 2022 18:35:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59668 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 59668-submit@debbugs.gnu.org id=B59668.16699196491816 (code B ref 59668); Thu, 01 Dec 2022 18:35:02 +0000 Original-Received: (at 59668) by debbugs.gnu.org; 1 Dec 2022 18:34:09 +0000 Original-Received: from localhost ([127.0.0.1]:41259 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p0oNs-0000TE-IQ for submit@debbugs.gnu.org; Thu, 01 Dec 2022 13:34:08 -0500 Original-Received: from mail-pj1-f52.google.com ([209.85.216.52]:47014) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p0oNp-0000Sq-9q for 59668@debbugs.gnu.org; Thu, 01 Dec 2022 13:34:06 -0500 Original-Received: by mail-pj1-f52.google.com with SMTP id b13-20020a17090a5a0d00b0021906102d05so2925366pjd.5 for <59668@debbugs.gnu.org>; Thu, 01 Dec 2022 10:34:05 -0800 (PST) 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=MXM1Kxgu1Z7q0G47eOY1Y6V1KaKZS1fqxoTIBi8VaFI=; b=WHoNlzjnIvq5OD0UY9QB9BpC5+Zjp4XjHIXyoqtV2qJHE7S1wY4BSKtmtZmTShbA9a S6gtBva3aNL0gTdEeKxiotAkHiiOyIQRbi7vmsctb5ef3ZRsbUjA1Af2keOXFbS+W6uZ /9wQHu5UmtQ0MfhwHpFac/3EIrnxtkkqOjD4Nr3l4WlmIHscTXzzBGAvS+/y/oLQquCv iRQd84d3LpCxWUb9jqshnRSJKEJ27gL6Ryizhks7g8YdZ2Q5Wp4Gkq4lay9UVFsLemYw brUKctCPqZd2Ddc67eQNk0weSoHQtRT+bvJDlzYWzD+dW03OfkSEQJYXwOPtKm2PHjny eobA== 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=MXM1Kxgu1Z7q0G47eOY1Y6V1KaKZS1fqxoTIBi8VaFI=; b=m8KColhI/VoH97lnJnfoWB91zAoYM1f/DOhe9nO/yQWlR2Oy71wy81wmTgW94hi4We YArlu0qGLqA6swRObig8DQTvg4VJMs7d8xyP7k/FHQJ4QSXqlGpJv9opzT5Z32DJiexF v4cad6q+fL4RxO4AxqbXzR+K1k60Y4b/TMawKRW6PRgUGVW7RslB5uczactto2IzAYe9 t1lc6BAN7dhw6PafeUrjfNIJI5qYf3TmE32kB5Rns1L0Hb8GC/LUC9Hu7A7Lpsh9i7o7 2SuXcSa1dArNnecSPmkCblMH0UpOCvB8twLfF/FqExUKlRgAJe/W6DrFZL1Fql+FFka+ HeKQ== X-Gm-Message-State: ANoB5pkPmN12F5vP9pPVCZwTUH7t5lrXJtlX6ZvGZ9ZzMonF+2O0flVF 1I2CkXzKRBHF3UHCbqixtKDPxph5ozo= X-Google-Smtp-Source: AA0mqf5Fbn0geplTZFu55k9PDPgh1AbRqDLK1cKU/qsJBnrqbZotnzBAMio4rZGHn6ITp494uwy6bw== X-Received: by 2002:a17:903:2350:b0:189:8ea3:7455 with SMTP id c16-20020a170903235000b001898ea37455mr20477738plh.19.1669919639298; Thu, 01 Dec 2022 10:33:59 -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 d11-20020a170902cecb00b00189327b022bsm3962738plg.286.2022.12.01.10.33.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 01 Dec 2022 10:33:58 -0800 (PST) Content-Language: en-US In-Reply-To: <83mt87gih4.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:249660 Archived-At: On 12/1/2022 9:08 AM, Eli Zaretskii wrote: >> Date: Mon, 28 Nov 2022 20:23:17 -0800 >> From: Jim Porter >> >> One question though: should this only go on the master branch, or should >> it go into the 29 branch? To me, it seems like it could go either way, >> though I think it'd be nice to make this easier for users in 29. I'll do >> whatever the maintainers think is best though. > > Let's not start installing new features on the release branch. ... Sounds good to me. >> If it goes on the master branch only, I'll add back the function form of >> 'server-stop-automatically' for compatibility, and then mark it obsolete. > > I see no reason to make the function obsolete. It does not harm to have > both a variable and a function by the same name. Fine by me. The function will just be a one-liner anyway: (setopt server-stop-automatically arg). > This @itemize list should be converted to a @table, formatted like this: > > @item empty > This value caused the server to be stopped when... > > @item delete-frame > This value means that when the last client frame is deleted... > > etc., I guess you get the idea. Will do. I made the minimal set of changes to the manual, but while I'm here, I agree that it would be good to improve things further. >> @@ -1780,7 +1784,8 @@ server-save-buffers-kill-terminal >> >> If emacsclient was started with a list of filenames to edit, then >> only these files will be asked to be saved." >> - (if server-stop-automatically >> + (if (and (daemonp) >> + (memq server-stop-automatically '(kill-terminal delete-frame)) > > Why is this needed? I guess I don't understand why non-trivial code changes > are in a patch that was supposed to just add a defcustom? It's due to a change in the meaning of the 'server-stop-automatically' value. Previously, it was an internal variable that was set to nil after calling "(server-stop-automatically 'empty)", or when calling 'server-stop-automatically' in a non-daemon session. Since 'server-stop-automatically' is now a defcustom, that means that a) it can really be set to 'empty', and b) it can be non-nil in non-daemon sessions. So this extra code is just to account for the change in meaning. I could make a helper function that returns the same value as the *old* version of the 'server-stop-automatically' variable; either way has the same meaning. I could also keep the old variable around, possibly renamed to something like 'server-stop-automatically--kill-terminal', but I think a helper function would be cleaner. >> +(defun server-apply-stop-automatically () >> + "Apply the current value of `server-stop-automatically'. >> +This function adds or removes the necessary helpers to manage >> +stopping the Emacs server automatically, depending on the whether >> +the server is running or not. This function only applies when >> +running Emacs as a daemon." > > And why this significant refactoring of the original function? was there > something wrong with it? The previous implementation was limited in that you could call it once, but you couldn't necessarily call it a second time to change the setting. For example, this would put you in an inconsistent state: (server-stop-automatically 'delete-frame) (server-stop-automatically 'empty) After this, the 'empty' setting would be enabled, and the 'delete-frame' setting would still be partially-enabled too. That wasn't so much of a problem when you'd just call this function only once in your init file, but for the Customize interface, I think it's important to make sure that users can set the defcustom multiple times, e.g. if they change their minds while customizing it. The changes for 'server-apply-stop-automatically' are to support that. As you said, these changes are more extensive than "just" adding a defcustom, but all the other changes are there to support the Customize interface.