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: Sun, 24 Oct 2021 14:49:39 -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="12373"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Oct 24 23:51:16 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 1melOe-00031o-D9 for ged-emacs-devel@m.gmane-mx.org; Sun, 24 Oct 2021 23:51:16 +0200 Original-Received: from localhost ([::1]:57646 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1melOd-0004hd-Ad for ged-emacs-devel@m.gmane-mx.org; Sun, 24 Oct 2021 17:51:15 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:60922) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1melNB-0003uW-Jz for emacs-devel@gnu.org; Sun, 24 Oct 2021 17:49:46 -0400 Original-Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]:54983) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1melN9-0002Lw-9X for emacs-devel@gnu.org; Sun, 24 Oct 2021 17:49:45 -0400 Original-Received: by mail-pj1-x102e.google.com with SMTP id np13so6775409pjb.4 for ; Sun, 24 Oct 2021 14:49:41 -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=v1B7Xxf5/WBZro+iifnilmhCEibt12g3t3uOgJciy+U=; b=F0pfynmc3dviEUhsuQLWkhFW36D5d08+iunLOiSDce52IIlwzCCcd/9GKIYHmEgyRz xEyL/uiksHtSzH/AJ/KwtHjRwLvO+R1W2g2ML2zMmUiIXzPpY/LbIiySrBTyjc1hVCaF fgVnjEaNT/8KllUE770JtETtbykOEdj6/azBF7nSHmPiBJ2fNVio+54EI9pnEy/Q9qAF AIEAW2/+mGHn/I5iOJbFIc4dJr0u9XoTd8GaCukgO1MegrSNjt+XykvfziFM2HGipaDN CAA3wafHIIDYOUJ0u8x5GSYYAJjBnL0Y4cb+uTIXYA4ZKQF+kTC2X3BZISVfbNQ+bQe8 7xxg== 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=v1B7Xxf5/WBZro+iifnilmhCEibt12g3t3uOgJciy+U=; b=TLMoYuY3DcBw2UVTAEHskRaw7nnWfdzYC6LEn5MUEsoYg6S47BkxliJjGc0vSavSSM yHb0O0piJc9xsd6pHbuR2Tyk9w8yJE13pU1DPMIB3ukjAlnD+CnlvCPlPGw9lttdF4/K BPnxVshFR6e0WoXXYOktjB6J1iGW6072x8wdyxR8IIwoYzMhQQD0/XXS8c817fZASvsU Qxv1MeLUeEj241AJOJ0YXdsiMZip7kCMZk8aTX1oaVFy5JnfeRkLfFuu8WpeqH/cRqda MXyvaeBW3b/zIumBZZTDW9IQglfuHrJRKJW9d1K+n98z4sqlLeUGduFbI+nFzkXtpy7n /kBw== X-Gm-Message-State: AOAM533hkudMB8epEvWrqlMe3V56sHSswtSZogWpzjaeat8Du+cPMFGd B8VIyCXYdr3q/+DgmYp8tBdwKG7WA/w= X-Google-Smtp-Source: ABdhPJxOVL1WanMuJpk21YdkeLUrKRmWz60YJl9Ce1uphySB0ervpmLbX2ZQ62dfYG7kFCoymFwsHA== X-Received: by 2002:a17:90a:e7cf:: with SMTP id kb15mr3423694pjb.14.1635112180917; Sun, 24 Oct 2021 14:49:40 -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 mu11sm23519786pjb.20.2021.10.24.14.49.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 24 Oct 2021 14:49:40 -0700 (PDT) In-Reply-To: Content-Language: en-US Received-SPF: pass client-ip=2607:f8b0:4864:20::102e; envelope-from=jporterbugs@gmail.com; helo=mail-pj1-x102e.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:277686 Archived-At: On 10/22/2021 4:58 AM, Stefan Monnier wrote: >> This would allow for a behavior similar to other (graphical) programs: if >> I run `firefox example.com', it starts a new instance as normal. If I run it >> again, it opens a new tab in the existing instance. If I close all the >> Firefox windows, all the associated processes terminate. > > 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. I posted a series of patches going this route here: (see also my followups in that bug). To briefly summarize, I added a `--lazy-daemon' flag that indicates the (background) daemon was started on-demand, and then consult that via a new function `daemon-type' to adjust the behavior. There's probably more work to be done with that (e.g. customization options for users to tweak the behavior to their preferences), but it works for me so far. Hopefully with actual patches showing what I'd like, it'll be easier for people to see precisely what behavior I'm after. Of course, if no one else has any interest in things working this way, then it might not make sense to merge the patches. No matter what, I can always take the Lisp portions for my own configuration so that things work the way I want. - Jim