From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#59668: 29.0.50; [PATCH] Make 'server-stop-automatically' into a defcustom Date: Thu, 01 Dec 2022 19:08:07 +0200 Message-ID: <83mt87gih4.fsf@gnu.org> References: <155f479d-3bae-c327-47a3-7b58daf912c0@gmail.com> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25045"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 59668@debbugs.gnu.org To: Jim Porter Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Dec 01 18:09:24 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 1p0n3s-0006JZ-2A for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 01 Dec 2022 18:09:24 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p0n3Y-0003Yq-Pz; Thu, 01 Dec 2022 12:09:04 -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 1p0n3W-0003Yf-VG for bug-gnu-emacs@gnu.org; Thu, 01 Dec 2022 12:09: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 1p0n3W-0001aK-N2 for bug-gnu-emacs@gnu.org; Thu, 01 Dec 2022 12:09:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p0n3W-00088P-67 for bug-gnu-emacs@gnu.org; Thu, 01 Dec 2022 12:09:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 01 Dec 2022 17:09: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.166991452231260 (code B ref 59668); Thu, 01 Dec 2022 17:09:02 +0000 Original-Received: (at 59668) by debbugs.gnu.org; 1 Dec 2022 17:08:42 +0000 Original-Received: from localhost ([127.0.0.1]:40862 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p0n3B-000888-V7 for submit@debbugs.gnu.org; Thu, 01 Dec 2022 12:08:42 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:52856) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p0n3A-000882-5e for 59668@debbugs.gnu.org; Thu, 01 Dec 2022 12:08:40 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p0n34-0001X0-QY; Thu, 01 Dec 2022 12:08:34 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=5TvXb/3yda+BhhsOVkphu00zUUDh0uAeVV8TNI/v1Tg=; b=pZfRLn5EhrBQ 5Z8ZrKalOwReVk1baSRuk420JZ7FFGOYxVfL9QsCpcv0M6WivZwX6RZxJr786+qSDeG4yzA0yC9gi BE1pAyqfhMylpV1SkaKGXQ6vIPdLa2MWvt7w1yiHs/Y+Hz2+CeXj0oUdhOCACiE/61+mlaKML/6jd qKW+Ky88DCsGW/WWngeYBxnnEFkj20eF2OyY8lCWR0kZ5TePFVHYrOfXMgu8ZSu1Q+z522HAWZ507 6ixLsS7tpQh//eaDfO0El6OWfrLmAEEHByJqqHd2TJItU42fp/ESCJ+6CttUdJoVs3r/w+nbtvhx3 44o969cfqnx63YRC1fiBZA==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p0n34-0003Mx-4H; Thu, 01 Dec 2022 12:08:34 -0500 In-Reply-To: <155f479d-3bae-c327-47a3-7b58daf912c0@gmail.com> (message from Jim Porter on Mon, 28 Nov 2022 20:23:17 -0800) 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:249653 Archived-At: > Date: Mon, 28 Nov 2022 20:23:17 -0800 > From: Jim Porter > > The Emacs server can optionally be stopped automatically when > certain conditions are met. To do this, call the function > @code{server-stop-automatically} in your init file (@pxref{Init > File}), with one of the following arguments... > > It'd be nice if this were a defcustom so that people who prefer the > Customize interface could use that instead of editing their init files. > Here's a patch for that. Thanks. > 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. We have enough new stuff there already. Besides, the changes you suggest are hardly trivial, and saying just "make a function into a defcustom" doesn't come close to describing it, IMO. So please install on master, once you take care of the comments below. > 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. > -@findex server-stop-automatically > +@vindex server-stop-automatically > The Emacs server can optionally be stopped automatically when > -certain conditions are met. To do this, call the function > -@code{server-stop-automatically} in your init file (@pxref{Init > -File}), with one of the following arguments: > +certain conditions are met. To do this, set the option > +@code{server-stop-automatically} to one of the following values: > > @itemize > @item > -With the argument @code{empty}, the server is stopped when it has no > +With the value @code{empty}, the server is stopped when it has no > clients, no unsaved file-visiting buffers and no running processes > anymore. > > @item > -With the argument @code{delete-frame}, when the last client frame is > +With the value @code{delete-frame}, when the last client frame is > being closed, you are asked whether each unsaved file-visiting buffer > must be saved and each unfinished process can be stopped, and if so, > the server is stopped. 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. > @@ -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? > +(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?