Subject: 30.0.50; [PATCH] Fallout 339893f
From: [email-masked]
To: bug-gnu-emacs <[email-masked]>
Date: Tue, 28 Feb 2023 14:21:24 -0500
List-Id: <debbugs-submit.debbugs.gnu.org>

From 7db3a36e3aa7ab1aba27258245eb7f02e46da354 Mon Sep 17 00:00:00 2001
From: dickmao <[email-masked]>
Date: Tue, 28 Feb 2023 14:16:53 -0500
Subject: [PATCH] Fallout 339893f

make TEST_INTERACTIVE=no test/lisp/server-tests
make TEST_INTERACTIVE=yes test/lisp/server-tests

* lisp/server.el (server-eval-and-print): Whitespace.
* test/lisp/server-tests.el (server-tests/wait-until): Drain
process output.
(server-tests/with-server): Whitespace.
(server-tests/server-start/sets-minor-mode): Whitespace.
(server-tests/server-start/stop-prompt-with-client,
server-tests/emacsclient/create-frame,
server-tests/server-force-stop/keeps-frames): Pass.
---
 lisp/server.el            | 15 +++++----------
 test/lisp/server-tests.el | 16 ++++++++--------
 2 files changed, 13 insertions(+), 18 deletions(-)

diff --git a/lisp/server.el b/lisp/server.el
index 35b38ef8fa6..9321bf4a3a7 100644
--- a/lisp/server.el
+++ b/lisp/server.el
@@ -854,16 +854,11 @@ server-mode
   ;; 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)))
-
+
 (defun server-eval-and-print (expr proc)
   "Eval EXPR and send the result back to client PROC."
-  ;; While we're running asynchronously (from a process filter), it is likely
-  ;; that the emacsclient command was run in response to a user
-  ;; action, so the user probably knows that Emacs is processing this
-  ;; emacsclient request, so if we get a C-g it's likely that the user
-  ;; intended it to interrupt us rather than interrupt whatever Emacs
-  ;; was doing before it started handling the process filter.
-  ;; Hence `with-local-quit' (bug#6585).
+  ;; with-local-quit to interrupt this emacsclient request, and not
+  ;; whatever Emacs was doing before it (Bug#6585).
   (let ((v (with-local-quit (eval (car (read-from-string expr)) t))))
     (when proc
       (with-temp-buffer
@@ -1659,7 +1654,7 @@ server-kill-buffer
 	   (let ((server-kill-buffer-running t))
 	     (when server-process
 	       (server-buffer-done (current-buffer) t))))))
-
+
 (defun server-edit (&optional arg)
   "Switch to next server editing buffer; say \"Done\" for current buffer.
 If a server buffer is current, it is marked \"done\" and optionally saved.
@@ -1983,7 +1978,7 @@ server-eval-at
 	    (read (decode-coding-string (server-unquote-arg answer)
 					'emacs-internal)))))))
 
-
+
 (provide 'server)
 
 ;;; server.el ends here
diff --git a/test/lisp/server-tests.el b/test/lisp/server-tests.el
index ffafa74925f..499dc0a22c2 100644
--- a/test/lisp/server-tests.el
+++ b/test/lisp/server-tests.el
@@ -2,7 +2,7 @@
 
 ;; Copyright (C) 2022-2023 Free Software Foundation, Inc.
 
-;; This file is part of GNU Emacs.
+;; This file is NOT part of GNU Emacs.
 
 ;; GNU Emacs is free software: you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
@@ -48,7 +48,7 @@ server-tests/wait-until
       (when (> (float-time (time-since start))
                server-tests/max-wait-time)
         (ert-fail (format "timed out waiting for %S to be non-nil" ',form)))
-      (sit-for 0.1))))
+      (accept-process-output nil 0.1))))
 
 (defun server-tests/start-client (args)
   "Run emacsclient, passing ARGS as arguments to it."
@@ -85,8 +85,8 @@ server-tests/with-server
          (let ((inhibit-message t))
            (server-start t t))
          (delete-directory temporary-file-directory t)
-         (should (null server-process))
-         (should (null server-clients))))))
+         (should-not server-process)
+         (should-not server-clients)))))
 
 (defmacro server-tests/with-client (client-symbol args exit-status &rest body)
   "Start an Emacs client with ARGS and evaluate BODY.
@@ -123,14 +123,14 @@ server-tests/server-start/sets-minor-mode
     (should (eq server-mode t))
     (should (memq 'server-mode global-minor-modes)))
   ;; Make sure stopping the server deactivates the minor mode.
-  (should (eq server-mode nil))
+  (should-not server-mode)
   (should-not (memq 'server-mode global-minor-modes)))
 
 (ert-deftest server-tests/server-start/stop-prompt-with-client ()
   "Ensure that stopping the server prompts when there are clients."
   (skip-unless server-tests/can-create-frames-p)
   (server-tests/with-server
-    (server-tests/with-client emacsclient '("-c") 'exit
+    (server-tests/with-client emacsclient `(,(if noninteractive "-t" "-c")) 'exit
       (should (length= (frame-list) 2))
       (cl-letf* ((yes-or-no-p-called nil)
                  ((symbol-function 'yes-or-no-p)
@@ -164,7 +164,7 @@ server-tests/emacsclient/create-frame
   (skip-unless server-tests/can-create-frames-p)
   (let ((starting-frame-count (length (frame-list))))
     (server-tests/with-server
-      (server-tests/with-client emacsclient '("-c") nil
+      (server-tests/with-client emacsclient `(,(if noninteractive "-t" "-c")) nil
       (should (length= (frame-list) (1+ starting-frame-count)))
       (should (eq (process-status emacsclient) 'run))
       (should (eq (frame-parameter (car (frame-list)) 'client)
@@ -195,7 +195,7 @@ server-tests/server-force-stop/keeps-frames
          terminal)
     (unwind-protect
         (server-tests/with-server
-          (server-tests/with-client emacsclient '("-c") 'exit
+          (server-tests/with-client emacsclient `(,(if noninteractive "-t" "-c")) 'exit
             (should (eq (process-status emacsclient) 'run))
             (should (length= (frame-list) (1+ starting-frame-count)))
 
-- 
2.38.1

In Commercial Emacs 0.3.1snapshot c5740af in dev (upstream 30.0.50,
x86_64-pc-linux-gnu) built on dick
Repository revision: c5740afac357fe88df82bf10b577d8e603363b2e
Repository branch: dev
Windowing system distributor 'The X.Org Foundation', version 11.0.12101003
System Description: Ubuntu 22.04.1 LTS

Configured using:
 'configure WERROR_CFLAGS=-Werror --prefix=/home/dick/.local
 --with-tree-sitter'
Configured features:
CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG JSON
TREE_SITTER LCMS2 LIBSELINUX LIBSYSTEMD LIBXML2 MODULES NOTIFY INOTIFY
PDUMPER PNG RSVG SECCOMP SOUND THREADS TIFF TOOLKIT_SCROLL_BARS WEBP X11
XDBE XIM XINPUT2 XPM GTK3 ZLIB
Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix