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.devel Subject: Re: [RFC] Option to kill `emacs --daemon' when closing the last client frame Date: Mon, 25 Oct 2021 11:06:05 -0700 Message-ID: References: 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="31916"; mail-complaints-to="usenet@ciao.gmane.io" To: Stefan Monnier , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Oct 25 20:08:59 2021 Return-path: Envelope-to: ged-emacs-devel@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 1mf4P5-00083a-9f for ged-emacs-devel@m.gmane-mx.org; Mon, 25 Oct 2021 20:08:59 +0200 Original-Received: from localhost ([::1]:37294 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mf4P3-00022f-O6 for ged-emacs-devel@m.gmane-mx.org; Mon, 25 Oct 2021 14:08:57 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54532) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mf4MP-00009A-2R for emacs-devel@gnu.org; Mon, 25 Oct 2021 14:06:15 -0400 Original-Received: from mail-pg1-x534.google.com ([2607:f8b0:4864:20::534]:45910) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mf4MK-0001zw-In for emacs-devel@gnu.org; Mon, 25 Oct 2021 14:06:10 -0400 Original-Received: by mail-pg1-x534.google.com with SMTP id f5so11698438pgc.12 for ; Mon, 25 Oct 2021 11:06:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=subject:to:references:from:message-id:date:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=k5/dGiy1jQVSfDdksegUkKIPDT0VGfZyaczNIayS828=; b=Ju88gBTawDveSPtCckmGc4N0vkBGCDCjDEkzjnd/U9JC2jzxY7z5Q5RBBvhsiozWuy oPJAeslpeYBBrSImglGF+Xo7sqUQdsYLdgF46sRTbERtACf9n7GX7C9AhlrVmqaM4d3j 0EETqxfCVZpyAw0bkBn0S0e6axy8dY3ChPo4Nn3WTh0PNZpIw7L5h1jgInpez6ZIorjD v6uZ4/nRGsP2i92Zmrx5L0zC3WuULN+ZBmcc16yxlrtOo0EPk5g/E1227FDXLy/yR0Mk VGBKTwNa0McDT58Has9jLjd7Ugo+fTgG6HT3OVZ/kG9DE1LlzSjF1jqIh0C7vKEFJKP9 E6/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:references:from:message-id:date :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=k5/dGiy1jQVSfDdksegUkKIPDT0VGfZyaczNIayS828=; b=vZrK5QgbklunhgwtEBWLU58eJOQUgTGwQWBFKaf/VekVtuvcPtoaav3O1SRCmMBOjT ABRycHzg8Me68QpZq45lX69Ca+uUL8Kkg1TNnJDWOceUh385sFsgjEvPGo8SPW0DAtIt pw0RXnkg1fnqPVEvpxinaQ4lXLahO9Qu9YpmMpiVBbW+2BmclI+V6z9ZUZFEj7rVDjWm xn4x7sizhOnqy/szaFowTTYiQ47DymNOVbxhBe1t3pnE7CexKwNjITvqTpyLzHXaDSkD j76hM1sU5btz5XXMPplyy6ENn4t0hGu+3WZUODnGkXRpalA+rwUd6mT6gqPQs4QNNG9B Rd9A== X-Gm-Message-State: AOAM5300b4Odqlr/4MQqDuK77swo7wNmHoktOWMT1vxkDArpkzUoMxQW 6NVc67gFXfVRu5emPegCwZ7tIiCYvMw= X-Google-Smtp-Source: ABdhPJxTohY3H+RlAh5vmKXzwMv8Kw2h3MYHe1oqA6RG1HGMo/QRb2PQRJtvCL2qzL5+KsHjXZYbuA== X-Received: by 2002:a05:6a00:114c:b0:47b:b98b:2210 with SMTP id b12-20020a056a00114c00b0047bb98b2210mr20573573pfm.75.1635185166898; Mon, 25 Oct 2021 11:06:06 -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 e7sm7023460pgk.90.2021.10.25.11.06.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 25 Oct 2021 11:06:06 -0700 (PDT) In-Reply-To: Content-Language: en-US Received-SPF: pass client-ip=2607:f8b0:4864:20::534; envelope-from=jporterbugs@gmail.com; helo=mail-pg1-x534.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:277778 Archived-At: On 10/24/2021 11:19 PM, Jean Louis wrote: > * Stefan Monnier [2021-10-22 14:59]: >> I guess it would make sense to try and distinguish the two cases: >> >> - Eager: `emacs --daemon` is run (typically from something like a login >> script or systemd) before any emacsclient is involved. >> - Lazy: `emacs --daemon` is started on-demand by the `-a` option >> of `emacsclient` (or via ALTERNATE_EDITOR). >> >> In the lazy case, we could kill the daemon when the last client exits. > > Can the variable `server-clients' help to detect how many clients are there? > > Then if so, one can make Emacs Lisp function and put in > configuration file, then such user can have the Emacs Daemon > killed if last client is closed. Yup, that's what I'm doing now. I use a slightly-tweaked version of the patch I posted to bug#51377[1] in my configuration. While I'm happy with my configuration now, I wanted to propose adding those changes to Emacs itself (with options to tweak the behavior as appropriate) if others would find it useful. - Jim [1] https://lists.gnu.org/archive/html/bug-gnu-emacs/2021-10/msg02209.html