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: Wed, 20 Oct 2021 20:43:31 -0700 Message-ID: References: <83h7dbc2sl.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="23330"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Oct 21 05:44:35 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 1mdP0N-0005rr-6b for ged-emacs-devel@m.gmane-mx.org; Thu, 21 Oct 2021 05:44:35 +0200 Original-Received: from localhost ([::1]:58806 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mdP0L-0004IF-U8 for ged-emacs-devel@m.gmane-mx.org; Wed, 20 Oct 2021 23:44:34 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:36640) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdOzQ-0003YO-Bl for emacs-devel@gnu.org; Wed, 20 Oct 2021 23:43:36 -0400 Original-Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]:51154) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mdOzO-0001yf-Sg; Wed, 20 Oct 2021 23:43:36 -0400 Original-Received: by mail-pj1-x102c.google.com with SMTP id gn3so3965076pjb.0; Wed, 20 Oct 2021 20:43:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=subject:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=vqZAm1yyrYgzorMjOcHiPz4NMTj7Ydit8snWGk4u46c=; b=c09oOBQrobnGo1AVBNpdbgUI4ORxA1/kDbnPJjFB4MP4nIiNoDbzDqelkn869pZ6Mg bYfB0rsUkWbyRS6ZPIHeBiDYS1nZ8YqygYiRo9XNIhNkxYq/UlzpQXpbBKoDGoDHGpA7 MZELtC8txQvzxEpv3gqvV502PhOXyvlou0XjVulGLf68iixNQ4GeHCxzk+BuX9YOdQih mzQYnmjwTdcAljI2RYseo7G0LWmhSoTz+JnJ45xSGopzecrAY7N6jUEhDB9ew7nmoAN1 Jo5K73JFNZ8IjenjN+5bij90k1B2cT8+OLXtiAj2QwbRTy110atjTvIQ9vNahP4KVs+u tmyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=vqZAm1yyrYgzorMjOcHiPz4NMTj7Ydit8snWGk4u46c=; b=YorCvpCoGTrH0wT56dPNMKiyi/mIPa12cgYLH/nVVS7Kq8cY7OUxKSghLEGioUaMks D2AR1ixWq3pbsQqEBrGrk3kxVQKF3rWjnKdjzSlmyhvX0RGzSHqsAQW/UTBSVACgC7DG e9t6dZ000DgWsnSZSCVUBwxJm46sI7rNPpGvkcCBFtwvwxa6i7l6UTZRdebbr1xsZj0G +xMNwxQya00XU/B5j9azwrjQcG/khI+JPB93pR8qT8AYSO+MVSvaOQwZdYkL3h5pUqAu 8BmFNXoNunPQcNeQ8WlxFK2Yr52GaEmVKEt3oSJ1EFOYB2bTeNzvETYXkK50krM1lSZz 3M8A== X-Gm-Message-State: AOAM5303q9sSQL7gWkC+pX9rlcPQj7Q2Mp3ZmSxCggCVrPiWQoNU5fs8 a08teOIzcb6z9zaOjlhFtVUP8NskGvg= X-Google-Smtp-Source: ABdhPJz5PfJRJ8jYuMT+CaIEDTAodSKAjd4l7lrpKt7Goi7d6d0AmsmyKbNwm9BK1sXvFwNFJQZ47Q== X-Received: by 2002:a17:90b:354:: with SMTP id fh20mr3696036pjb.188.1634787811848; Wed, 20 Oct 2021 20:43:31 -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 s28sm3542755pgo.86.2021.10.20.20.43.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 20 Oct 2021 20:43:31 -0700 (PDT) In-Reply-To: <83h7dbc2sl.fsf@gnu.org> Content-Language: en-US Received-SPF: pass client-ip=2607:f8b0:4864:20::102c; envelope-from=jporterbugs@gmail.com; helo=mail-pj1-x102c.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:277494 Archived-At: On 10/20/2021 5:13 AM, Eli Zaretskii wrote: > Unlike "other programs", Emacs doesn't aim to support such use > patterns with the ALTERNATE_EDITOR thing. It is supposed to allow the > user to invoke emacsclient without knowing whether a server already > runs, by starting the server the first time. That is why we don't > kill the server when the last client exits: it is against the use case > we want to support. My expectation (which is really just personal preference informed by other programs I'm used to) is that since `emacs --daemon' is created on as-needed basis in this configuration, it would also be killed when it's no longer needed. If I wanted `emacs --daemon' to live forever, I'd probably just set it up to start when my system boots. However, I don't know if I can make a particularly compelling argument as to why this *should* be how things work, aside from just saying that I find the symmetry of this behavior simpler/easier to remember. It's in the same vein as a refcounted object in a program (e.g. `std::shared_ptr' for C++ programmers): I can make new `emacsclient's, which increment the refcount, and once the refcount drops to 0, the underlying entity (i.e. the daemon) is automatically cleaned up. In the end though, it's just what I like / what makes the most sense to me. If other people see things similarly, I'd be happy to write a patch, but if I'm the only one who wants this, then I can always customize my .emacs to my liking instead. > We could add an optional command-line argument to do what you want, > but I wonder why would that be useful, when we already have > kill-emacs. That's one option, although it might take a bit of work to support that (assuming I understand what you mean). As far as I understand how ALTERNATE_EDITOR works, there's not an easy way to automatically start the Emacs daemon *and* provide it with some extra options. That is, ALTERNATE_EDITOR="emacs --daemon --foo" would start the daemon, but wouldn't create a client to connect to it. Another method might be to add an option like `daemon-kill-when-no-clients' that defaults to nil. Then after an `emacsclient' is killed, we can consult that variable, and if it's true, kill the daemon if there are no remaining clients. - Jim