unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Jim Porter <jporterbugs@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 58909@debbugs.gnu.org
Subject: bug#58909: 29.0.50; [PATCH] Deleting the last frame of an emacsclient doesn't ask to save
Date: Wed, 2 Nov 2022 15:09:21 -0700	[thread overview]
Message-ID: <1e0f9cc1-03ed-9eea-c6cb-56248607dfe3@gmail.com> (raw)
In-Reply-To: <83zgd986fi.fsf@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 1159 bytes --]

On 11/2/2022 1:09 PM, Eli Zaretskii wrote:
>> 'server-delete-client' is called in a bunch of spots, so at minimum, I'd
>> want to be extra-careful that prompting doesn't break one of those
>> cases.
> 
> Sorry, I meant server-handle-delete-frame.

Oh, ok. That would be easy then. But since your preference was to just 
leave things as they are, let's not make this change. I can adjust 
things locally without it.

>>>> If starting the server activates a minor mode, then Emacs can use a
>>>> minor-mode keymap for server-mode. [snip]
>>>
>>> I'm fine with doing that, but we must also make sure this mode is
>>> turned on when users invoke server-start interactively.
>>
>> I think that makes sense, and it should be fairly straightforward. I'll
>> work on a patch for this.
> 
> Thanks.

Ok, here's a patch for that. It just sets the 'server-mode' variable 
(and 'global-minor-modes' to be polite) inside 'server-start'. It would 
probably be more elegant if we could make 'server-start' just call 
'(server-mode)' (instead of the other way around like it is now), but I 
think it would be hard to do that while staying 100% compatible. Does 
this seem ok?

[-- Attachment #2: 0001-Enable-disable-server-mode-when-starting-stopping-th.patch --]
[-- Type: text/plain, Size: 2452 bytes --]

From 687f2ab4803c41f6a33280048243b0962816d2b5 Mon Sep 17 00:00:00 2001
From: Jim Porter <jporterbugs@gmail.com>
Date: Wed, 2 Nov 2022 09:22:43 -0700
Subject: [PATCH] Enable/disable 'server-mode' when starting/stopping the
 server

* lisp/server.el (server-mode-keymap): New keymap...
(server-mode): ... use it.
(server-start): Update the 'server-mode' variable (and sync to
'global-minor-modes') when starting/stopping the server.
---
 lisp/server.el | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/lisp/server.el b/lisp/server.el
index 90d97c1538..18548186b1 100644
--- a/lisp/server.el
+++ b/lisp/server.el
@@ -670,7 +670,6 @@ server-start
                             "/tmp/")
                  (ignore-errors
                    (delete-directory (file-name-directory server-file))))))
-         (setq server-mode nil) ;; already set by the minor mode code
          (display-warning
           'server
           (concat "Unable to start the Emacs server.\n"
@@ -688,7 +687,9 @@ server-start
       (if leave-dead
 	  (progn
 	    (unless (eq t leave-dead) (server-log (message "Server stopped")))
-	    (setq server-process nil))
+            (setq server-mode nil
+                  global-minor-modes (delq 'server-mode global-minor-modes)
+                  server-process nil))
 	;; Make sure there is a safe directory in which to place the socket.
 	(server-ensure-safe-dir server-dir)
 	(when server-process
@@ -728,6 +729,8 @@ server-start
 			       :plist '(:authenticated t)))))
 	  (unless server-process (error "Could not start server process"))
 	  (process-put server-process :server-file server-file)
+          (setq server-mode t)
+          (push 'server-mode global-minor-modes)
 	  (when server-use-tcp
 	    (let ((auth-key (server-get-auth-key)))
 	      (process-put server-process :auth-key auth-key)
@@ -796,6 +799,10 @@ server-running-p
 	t)
     (file-error nil)))
 
+;; This keymap is empty, but allows users to define keybindings to use
+;; when `server-mode' is active.
+(defvar-keymap server-mode-keymap)
+
 ;;;###autoload
 (define-minor-mode server-mode
   "Toggle Server mode.
@@ -805,6 +812,7 @@ server-mode
 `server-start' for details."
   :global t
   :version "22.1"
+  :keymap server-mode-keymap
   ;; Fixme: Should this check for an existing server socket and do
   ;; nothing if there is one (for multiple Emacs sessions)?
   (server-start (not server-mode)))
-- 
2.25.1


  reply	other threads:[~2022-11-02 22:09 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-30 22:29 bug#58909: 29.0.50; [WIP PATCH] Deleting the last frame of an emacsclient doesn't ask to save Jim Porter
2022-10-31 12:44 ` Eli Zaretskii
2022-10-31 17:36   ` Jim Porter
2022-10-31 18:25     ` Eli Zaretskii
2022-10-31 19:38       ` Jim Porter
2022-10-31 19:52         ` Eli Zaretskii
2022-10-31 20:28           ` Jim Porter
2022-11-01  6:17             ` Eli Zaretskii
2022-10-31 19:28   ` Jim Porter
2022-10-31 19:43     ` Eli Zaretskii
2022-10-31 20:01       ` Jim Porter
2022-10-31 20:21         ` Eli Zaretskii
2022-10-31 21:06           ` Jim Porter
2022-11-01  6:39             ` Eli Zaretskii
2022-11-01 16:11               ` Jim Porter
2022-11-01 22:39                 ` Jim Porter
2022-11-02 12:16                   ` Eli Zaretskii
2022-11-02 16:36                     ` Jim Porter
2022-11-02 17:11                       ` Eli Zaretskii
2022-11-02 18:17                         ` Jim Porter
2022-11-02 18:42                           ` Eli Zaretskii
2022-11-02 19:16                             ` Jim Porter
2022-11-02 19:23                               ` Eli Zaretskii
2022-11-02 19:57                                 ` Jim Porter
2022-11-02 20:09                                   ` Eli Zaretskii
2022-11-02 22:09                                     ` Jim Porter [this message]
2022-11-03  6:25                                       ` bug#58909: 29.0.50; [PATCH] " Eli Zaretskii
2022-11-06 20:23                                         ` Jim Porter
2022-11-08 14:47                                           ` Eli Zaretskii
2022-11-08 15:08                                             ` Robert Pluim
2022-11-08 15:13                                               ` Eli Zaretskii
2022-11-08 15:29                                                 ` Robert Pluim
2022-11-08 16:52                                                   ` Jim Porter
2022-11-09 10:06                                                     ` Robert Pluim
2022-11-17  5:17                                                       ` Jim Porter
2023-09-07 21:03                                                         ` bug#58909: 29.0.50; [WIP PATCH] " Stefan Kangas
2023-09-08  1:21                                                           ` Jim Porter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1e0f9cc1-03ed-9eea-c6cb-56248607dfe3@gmail.com \
    --to=jporterbugs@gmail.com \
    --cc=58909@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).