unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Carlos Pita <carlosjosepita@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: Juanma Barranquero <lekktu@gmail.com>, 37826@debbugs.gnu.org
Subject: bug#37826: Very annoying autoraise client/server behavior with -t option
Date: Mon, 21 Oct 2019 17:14:32 -0300	[thread overview]
Message-ID: <CAELgYhf=6_q98psZEWO1i8YXoCRwNcMe_JwQoE+aHW2u6DGKMw@mail.gmail.com> (raw)
In-Reply-To: <CAELgYhdYQ+DKqGPBE4FEXqqt7CyQHMEAG8xp+O+PP8yTR9+NDg@mail.gmail.com>

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

> 1. Perhaps I'd have preferred to advice only around
> find-file-noselect, but this would probably require using a global
> variable to pass delayed messages from server-visit-files to
> server-execute. Thus I wrapped the entire server-visit-files call and
> keep the messages local to server-execute.

Regarding this point I've changed my mind after more carefully
inspecting server-visit-files. There are many hooks involved that
might run arbitrary code and therefore show messages. We're pretty
confident that any code requiring interaction will work anyway and all
delayed messages are going to be shown afterwards, so even
disregarding the global variable argument above, I still prefer the
version wrapping the entire call to server-visit-files to a more
selective one.

> 2. Also I'd have liked that the mock message function returned the
> formatted message (since it's part of the interface) but there are
> some corner cases (nil, non-string, empty first parameter) that force
> me to replicate much of the actual implementation (Fmessage), which I
> dislike.

I've addressed this point in the less sketchy patch I'm attaching, it
was simpler than I'd though, I believe I'm covering all input cases.

If you prefer to do minor reviews online, this is the commit in my
fork of your mirror
https://github.com/memeplex/emacs/commit/9d53e50848d9d8be758a21d0b5e078f82af25754.
I could create a PR also, just for the sake of reviewing, but it seems
like individual commits are also commentable (until my next forced
push deletes all comments, at least :).

Btw, here is another noisy case: when visiting a new file you get a
"(New file)" message.

[-- Attachment #2: 0001-Avoid-auto-raising-minibufer-before-new-frame-is-cre.patch --]
[-- Type: text/x-patch, Size: 1998 bytes --]

From 9d53e50848d9d8be758a21d0b5e078f82af25754 Mon Sep 17 00:00:00 2001
From: memeplex <carlosjosepita@gmail.com>
Date: Mon, 21 Oct 2019 17:04:38 -0300
Subject: [PATCH] Avoid auto-raising minibufer before new frame is created
 (Bug#37826)

* lisp/server.el (server-execute): Advice `message' to delay output
until the new frame is created.
---
 lisp/server.el | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/lisp/server.el b/lisp/server.el
index 45fa55ad6b..6fab0ef747 100644
--- a/lisp/server.el
+++ b/lisp/server.el
@@ -1304,7 +1304,16 @@ server-execute
   ;; including code that needs to wait.
   (with-local-quit
     (condition-case err
-        (let* ((buffers (server-visit-files files proc nowait))
+        (let* (;; Delay messages to avoid auto raising frame (Bug#37826).
+               (messages nil)
+               (delay (lambda (_ fmt &rest args)
+                        (let ((msg (and fmt (apply #'format-message fmt args))))
+                          (car (push msg messages)))))
+               (buffers (unwind-protect
+                            (progn
+                              (advice-add #'message :around delay)
+                              (server-visit-files files proc nowait))
+                          (advice-remove #'message delay)))
                ;; If we were told only to open a new client, obey
                ;; `initial-buffer-choice' if it specifies a file
                ;; or a function.
@@ -1325,6 +1334,10 @@ server-execute
                           ;; Switch to initial buffer in case the frame was reused.
                           (when initial-buffer
                             (switch-to-buffer initial-buffer 'norecord))))))
+          ;; Show all delayed messages in the new frame (if any).
+          (with-selected-frame (or frame (selected-frame))
+            (dolist (msg (nreverse messages))
+              (message msg)))
 
           (mapc #'funcall (nreverse commands))
 
-- 
2.20.1


  reply	other threads:[~2019-10-21 20:14 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-19 20:46 bug#37826: Very annoying autoraise client/server behavior with -t option Carlos Pita
2019-10-19 21:39 ` Carlos Pita
2019-10-20  6:23   ` Eli Zaretskii
2019-10-21  8:58     ` Carlos Pita
2019-10-21 10:22       ` Eli Zaretskii
2019-10-21 13:37         ` Carlos Pita
2019-10-21 13:53           ` Eli Zaretskii
2019-10-21 14:18             ` Carlos Pita
2019-10-21 14:52               ` Carlos Pita
2019-10-21 15:13                 ` Carlos Pita
2019-10-21 16:19                 ` Eli Zaretskii
2019-10-21 16:13               ` Eli Zaretskii
2019-10-21 16:21                 ` Carlos Pita
2019-10-21 16:33                   ` Carlos Pita
2019-10-21 16:39                     ` Eli Zaretskii
2019-10-21 16:37                   ` Eli Zaretskii
2019-10-21 15:56             ` Juanma Barranquero
2019-10-21 16:26               ` Eli Zaretskii
2019-10-21 17:02                 ` Juanma Barranquero
2019-10-21 17:13                   ` Eli Zaretskii
2019-10-21 18:40                     ` Carlos Pita
2019-10-21 20:14                       ` Carlos Pita [this message]
2019-10-26 10:57                         ` Eli Zaretskii
2019-10-26 15:53                           ` Carlos Pita
2019-10-26 19:02                             ` Eli Zaretskii
2019-10-26 20:27                               ` Carlos Pita
2019-10-27  5:22                                 ` Eli Zaretskii
2019-10-27  5:45                                   ` Carlos Pita
2019-10-27  6:02                                     ` Eli Zaretskii
2019-10-27 15:04                                       ` Carlos Pita
2019-10-27 15:31                                         ` Eli Zaretskii
2019-10-27 16:31                                           ` Carlos Pita
2019-10-27 16:36                                             ` Eli Zaretskii
2019-10-27 17:02                                               ` Carlos Pita
2019-10-27 17:09                                                 ` Eli Zaretskii
2019-10-27 17:19                                                   ` Carlos Pita
2019-10-27 17:50                                                     ` Eli Zaretskii
2019-11-07 17:23                                                       ` Eli Zaretskii
2020-08-09 16:12                                                         ` Lars Ingebrigtsen
2020-08-09 17:16                                                           ` Eli Zaretskii
2020-08-09 17:26                                                             ` Lars Ingebrigtsen
2019-10-22 14:46                     ` Juanma Barranquero
2019-10-21 13:55           ` Carlos Pita
2019-10-21 13:58             ` Eli Zaretskii
2019-10-20  5:55 ` Eli Zaretskii

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='CAELgYhf=6_q98psZEWO1i8YXoCRwNcMe_JwQoE+aHW2u6DGKMw@mail.gmail.com' \
    --to=carlosjosepita@gmail.com \
    --cc=37826@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=lekktu@gmail.com \
    /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).