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: 58877@debbugs.gnu.org
Subject: bug#58877: 29.0.50; [PATCH] When killing Emacs from a client frame with no other frames, Emacs shows a useless error prompt
Date: Sun, 27 Nov 2022 17:28:41 -0800	[thread overview]
Message-ID: <393cb671-cfab-8e7e-6229-b59a1e376e1b@gmail.com> (raw)
In-Reply-To: <cab15b03-91b8-b72d-bdd5-77c02f4b2b6c@gmail.com>

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

On 11/26/2022 1:44 PM, Jim Porter wrote:
> On 11/26/2022 12:35 PM, Eli Zaretskii wrote:
>>> Date: Sat, 26 Nov 2022 12:17:59 -0800
>>> Cc: 58877@debbugs.gnu.org
>>> From: Jim Porter <jporterbugs@gmail.com>
>>>
>>> Unless you have an idea for how to fix that (I've got no clue,
>>> unfortunately), how about just skipping these tests on MS Windows, with
>>> a comment explaining what the limitation is?
>>
>> Fine with me, thanks.
> 
> Thanks. I've merged the fixes for the tests as 
> 14d54212ea46dbd8c950c9852318597e0e47908d. If you see any other issues, 
> just let me know.

Here's one tiny followup fix. Currently on master, if you restart the 
Emacs server, it emits a "Server stopped" message. That's not right, and 
it should do what it used to: emit a "Restarting server" message. Here's 
a fix.

[-- Attachment #2: 0001-Don-t-emit-a-Server-stopped-message-when-restarting-.patch --]
[-- Type: text/plain, Size: 3494 bytes --]

From 1724f23f3d8b3bef18bcd97e2f892e943f03c0da Mon Sep 17 00:00:00 2001
From: Jim Porter <jporterbugs@gmail.com>
Date: Sun, 27 Nov 2022 17:22:49 -0800
Subject: [PATCH] ; Don't emit a "Server stopped" message when restarting the
 Emacs server

* lisp/server.el (server-stop): Return non-nil when we actually stop
the server.  Don't message about stopping the server here (but do log
it).
(server-start): Emit the appropriate message about stopping or
restarting the server.
---
 lisp/server.el | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/lisp/server.el b/lisp/server.el
index 2102f8569b..1b027f88ce 100644
--- a/lisp/server.el
+++ b/lisp/server.el
@@ -619,20 +619,22 @@ server--file-name
 
 (defun server-stop (&optional noframe)
   "If this Emacs process has a server communication subprocess, stop it.
-If the server is running in some other Emacs process (see
+If this actually stopped the server, return non-nil.  If the
+server is running in some other Emacs process (see
 `server-running-p'), signal a `server-running-external' error.
 
 If NOFRAME is non-nil, don't delete any existing frames
 associated with a client process.  This is useful, for example,
 when killing Emacs, in which case the frames will get deleted
 anyway."
-  (let ((server-file (server--file-name)))
+  (let ((server-file (server--file-name))
+        stopped-p)
     (when server-process
       ;; Kill it dead!
       (ignore-errors (delete-process server-process))
-      (unless noframe
-        (server-log (message "Server stopped")))
-      (setq server-process nil
+      (server-log "Stopped server")
+      (setq stopped-p t
+            server-process nil
             server-mode nil
             global-minor-modes (delq 'server-mode global-minor-modes)))
     (unwind-protect
@@ -658,7 +660,8 @@ server-stop
                                   server-name))))
       ;; If this Emacs already had a server, clear out associated status.
       (while server-clients
-        (server-delete-client (car server-clients) noframe)))))
+        (server-delete-client (car server-clients) noframe)))
+    stopped-p))
 
 ;;;###autoload
 (defun server-start (&optional leave-dead inhibit-prompt)
@@ -702,7 +705,8 @@ server-start
         (if (and internal--daemon-sockname
                  (not server--external-socket-initialized))
             (setq server--external-socket-initialized t)
-          (server-stop))
+          (when (server-stop)
+            (message (if leave-dead "Stopped server" "Restarting server"))))
       (server-running-external
        (display-warning
         'server
@@ -717,8 +721,6 @@ server-start
       (let ((server-file (server--file-name)))
 	;; Make sure there is a safe directory in which to place the socket.
 	(server-ensure-safe-dir (file-name-directory server-file))
-	(when server-process
-	  (server-log (message "Restarting server")))
         (with-file-modes ?\700
 	  (add-hook 'suspend-tty-functions #'server-handle-suspend-tty)
 	  (add-hook 'delete-frame-functions #'server-handle-delete-frame)
@@ -756,7 +758,7 @@ server-start
 			       :service server-file
 			       :plist '(:authenticated t)))))
 	  (unless server-process (error "Could not start server process"))
-          (server-log "Starting server")
+          (server-log "Started server")
 	  (process-put server-process :server-file server-file)
           (setq server-mode t)
           (push 'server-mode global-minor-modes)
-- 
2.25.1


  reply	other threads:[~2022-11-28  1:28 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-29 21:33 bug#58877: 29.0.50; [PATCH] When killing Emacs from a client frame with no other frames, Emacs shows a useless error prompt Jim Porter
2022-10-30  6:14 ` Eli Zaretskii
2022-10-30 21:14   ` Jim Porter
2022-11-22  5:06     ` Jim Porter
2022-11-24 11:51       ` Eli Zaretskii
2022-11-25  1:36         ` Jim Porter
2022-11-25 13:25           ` Eli Zaretskii
2022-11-25 19:31             ` Jim Porter
2022-11-25 20:18               ` Eli Zaretskii
2022-11-25 20:57                 ` Jim Porter
2022-11-26 14:43                   ` Eli Zaretskii
2022-11-26 19:04                     ` Jim Porter
2022-11-26 19:45                       ` Eli Zaretskii
2022-11-26 20:17                         ` Jim Porter
2022-11-26 20:35                           ` Eli Zaretskii
2022-11-26 21:44                             ` Jim Porter
2022-11-28  1:28                               ` Jim Porter [this message]
2022-11-28  3:31                                 ` Eli Zaretskii
2022-11-28  6:27                                   ` 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=393cb671-cfab-8e7e-6229-b59a1e376e1b@gmail.com \
    --to=jporterbugs@gmail.com \
    --cc=58877@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).