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#58909: 29.0.50; [WIP PATCH] Deleting the last frame of an emacsclient doesn't ask to save Date: Wed, 2 Nov 2022 12:16:30 -0700 Message-ID: <3d5bc685-889f-f406-0979-10f61db5d1a7@gmail.com> References: <9a70f868-ca50-52fc-af3e-23813af104f2@gmail.com> <83zgdcduxm.fsf@gnu.org> <53238b5b-3e0a-3dfe-eeba-f37cafa81f50@gmail.com> <838rkveq3n.fsf@gnu.org> <7de45884-b4c9-4a4c-777c-5db17b3bacca@gmail.com> <835yfzeobt.fsf@gnu.org> <7694fcf2-8982-9099-5eb8-39835d049847@gmail.com> <83y1svch5u.fsf@gnu.org> <0dc07894-dfa1-01f6-87c4-9e02bfcaf0dc@gmail.com> <83bkppblh7.fsf@gnu.org> <83a6599t7m.fsf@gnu.org> <39e03350-2783-fa90-5d66-26e47abe100d@gmail.com> <835yfx9p0z.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------bpnISdrr0zmHqJcaC0uzVk0o" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40678"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 58909@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Nov 02 20:17:23 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 1oqJEn-000APv-Ub for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 02 Nov 2022 20:17:22 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oqJEV-0001dp-Rc; Wed, 02 Nov 2022 15:17:03 -0400 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 1oqJEU-0001dW-RP for bug-gnu-emacs@gnu.org; Wed, 02 Nov 2022 15:17:02 -0400 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 1oqJEU-0000cd-Hi for bug-gnu-emacs@gnu.org; Wed, 02 Nov 2022 15:17:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oqJEU-00019K-5o for bug-gnu-emacs@gnu.org; Wed, 02 Nov 2022 15:17:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Jim Porter Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 02 Nov 2022 19:17:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58909 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 58909-submit@debbugs.gnu.org id=B58909.16674166004385 (code B ref 58909); Wed, 02 Nov 2022 19:17:02 +0000 Original-Received: (at 58909) by debbugs.gnu.org; 2 Nov 2022 19:16:40 +0000 Original-Received: from localhost ([127.0.0.1]:47205 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oqJE7-00018f-GE for submit@debbugs.gnu.org; Wed, 02 Nov 2022 15:16:40 -0400 Original-Received: from mail-pg1-f172.google.com ([209.85.215.172]:41642) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oqJE3-00018P-N5 for 58909@debbugs.gnu.org; Wed, 02 Nov 2022 15:16:38 -0400 Original-Received: by mail-pg1-f172.google.com with SMTP id q71so17061608pgq.8 for <58909@debbugs.gnu.org>; Wed, 02 Nov 2022 12:16:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=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=RKbl+a7G9pDemKl8f4rVoIrrxXLc+iQpmPBJs5GkcWE=; b=kcL1tTUnknv+Z8h3vDkvcdJzWYnhAhaFBkE31VWvggui6udDi39AqjROeslFk9kzdN oLmtufUiotcSEnFryvinCeo6M79uSKFZtLHMdkYplch7XkNRH+Nz+cho078QM2c2QNu3 PDfvouYY8kbbyU5zqDqo7GsMGcE59gxN3fZoEkdNzl/JTPf8xLKfQbGa1U9d6JaKtZa4 dxbi9gemtLoBEeod/vsB00v/jygJURTz8s7eDdyI6U7EoWlFxuWg3mjE5UBoOu0W1tV5 mqn5Y82d905N2gd7vDikEUjuJBjxRmgIZUnLa7OOZd3cPQQRY4Je9+4pM+FAV9ecRg2q pabQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=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=RKbl+a7G9pDemKl8f4rVoIrrxXLc+iQpmPBJs5GkcWE=; b=O6pWO6Gay3GW1ZGyuBt7QeQXuUc73L9dPvuakLyBXobc5tQa9fn3vy2agIvzagjCwN nRZx7sU+n8EZFCmvJckPWwclMguVWrMoumUYjHZm6LozryNYe4aXwryxR4GEWdSjpZFE I+EqJvLf4H6jGcvMdDS3lOBPUwYlGNLTbc6Bt0Zt2otsouvc5N57sFMVmswnEgnnowR6 9dhyMRBJPnuTRcP1WjdTCGciH4Nvsn7oprsQ6etvR+ydP/xwKero086LdYgRNaxQiPqL njB8zg9B7GG5sksiF2JUC6CMfYMe9azItFlMvHrMnT03OLQWi23JEK/6gio/zOM/2hbv aXLw== X-Gm-Message-State: ACrzQf1ukUVlqx2x+4y5IKXEGuo1J3wYGcNZfKvFWMApxId56dCWRKnl wJ9fAYuZX0JLVFz4i65uKgc= X-Google-Smtp-Source: AMsMyM4oGOH31CZR5CBeCbV3eogNtxsTLnqfNMWKmAtLr28RWwQmW9yFT09xp+mGECNKOY7uOzfxZw== X-Received: by 2002:aa7:9624:0:b0:56c:8c13:27bf with SMTP id r4-20020aa79624000000b0056c8c1327bfmr26883680pfg.20.1667416589649; Wed, 02 Nov 2022 12:16:29 -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 jc13-20020a17090325cd00b0017f7e0f4a4esm8666465plb.35.2022.11.02.12.16.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 02 Nov 2022 12:16:28 -0700 (PDT) Content-Language: en-US In-Reply-To: <835yfx9p0z.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: , Original-Sender: "bug-gnu-emacs" Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:246889 Archived-At: This is a multi-part message in MIME format. --------------bpnISdrr0zmHqJcaC0uzVk0o Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 11/2/2022 11:42 AM, Eli Zaretskii wrote: >> Date: Wed, 2 Nov 2022 11:17:00 -0700 >> Cc: 58909@debbugs.gnu.org >> From: Jim Porter >> >>> If that's because you want to support the C-g case, then don't: that >>> is a separate problem. >> >> Yeah, this subthread about 'delete-frame' was just to support the C-g >> case. Aside from that, I think doing this inside 'server-delete-client' >> would be fine. However, at least for this bug, adding a hook that runs >> in 'server-delete-client' doesn't add anything that >> 'delete-frame-functions' doesn't already allow. ('server-delete-client' >> is called from a hook in 'delete-frame-functions' in this case anyway.) > > We cannot have behavior specific to server.el coded outside of > server.el. So I don't think I understand what you are saying here. > My suggestion is not to add a hook, it is to add a prompt for the user > when the last client frame is deleted, and do it optionally. I just meant that the existing 'delete-frame-functions' hook lets me do what I want by writing a hook in my local configuration (except for the C-g issue). I agree that for any changes to Emacs, the changes should be in server.el as much as possible. >> If you mean adding a defcustom, I thought we'd agreed not to do that >> (see the beginning of your message here[1]). > > Yes, but you keep pushing... Sorry if I seem pushy. I really am open to different solutions here, and I just want to present some various options I see to make it possible/easy to adjust the behavior of server.el. My goal is really just to offer what improvements I can to Emacs; if they don't belong, that's ok. I can just use them locally. In short, consider my messages/patches as just an offer to help. > I'm not sure I understand the purpose of this minor mode, and we > ourselves start the server in the daemon mode by a direct call to > server-start. Also, server-start is a command, and many users (myself > included) invoke it interactively. > > Why is it important to have the mode turned on? What can a mode do > that we cannot do without a mode? If starting the server activates a minor mode, then Emacs can use a minor-mode keymap for server-mode. That would make it easy for users to add keybindings that only take effect when the server is running. In my case, I could locally remap 'delete-frame' to some new function when the server is running, and then I could make that function do exactly what I want. Other users might want to add other keybindings to this keymap (maybe one for 'server-edit-abort'). In fact, for my purposes, even just having daemon mode call '(server-mode 1)' instead of '(server-start)' would be a good improvement. There are other ways to do this, but having a minor mode makes it easier. I attached a quick patch that shows the changes I'd make so that users could have a 'sever-mode-keymap' to add to; if you think any of these changes are too risky, I don't mind removing them. If you think *all* of them are too risky, that's ok too. I can just do something equivalent in my local config. --------------bpnISdrr0zmHqJcaC0uzVk0o Content-Type: text/plain; charset=UTF-8; name="0001-WIP-Try-using-a-keymap-for-server-mode.patch" Content-Disposition: attachment; filename="0001-WIP-Try-using-a-keymap-for-server-mode.patch" Content-Transfer-Encoding: base64 RnJvbSAwZTYzOGU0YjE0ODFlNjBiNmQ4MjExYjE1ZDU1ZDNmZGU2Mjkx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