From: Aaron Jensen <aaronjensen@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 26995@debbugs.gnu.org
Subject: bug#26995: 26.0.50; emacsclient --tty FILE flashes previous frame's buffer before loading FILE
Date: Mon, 5 Feb 2018 01:56:22 -0500 [thread overview]
Message-ID: <CAHyO48ww-F_MVyyZTfwD7=QzYYsv=88+Z8iRMyPCHeGmV+NQDg@mail.gmail.com> (raw)
In-Reply-To: <837f1c3ggd.fsf@gnu.org>
[-- Attachment #1: Type: text/plain, Size: 951 bytes --]
From: Eli Zaretskii (mailto:eliz@gnu.org)
> > From: Aaron Jensen
> > > I can indeed reproduce the described behavior, but I see the same in
> > > Emacs 25.2 and in Emacs 24.5. The reason is simple: the way server.el
> > > is written, we first create the client frame, and only then show the
> > > file there. So the frame is created with no file to visit, and Emacs
> > > always shows the last buffer in the new frame in those cases.
> >
> > I see, so not a bug then. Is it possible to (easily) improve its behavior?
>
> It should be possible, but AFAICT it would need restructuring
> server-process-filter works.
Please see attached patch and let me know if this method is
acceptable. It’s perhaps a little kludgy because sometimes a frame is
created and sometimes it isn’t so we need both methods of ensuring the
initial frame is set properly. This does appear to work for all
scenarios I tested, however.
Thanks,
Aaron
[-- Attachment #2: 0001-Show-initial-buffer-immediately-upon-frame-creation-.patch --]
[-- Type: application/octet-stream, Size: 5488 bytes --]
From e1a8f19c5ec119202a2df934bf3175e2a4fdd4a8 Mon Sep 17 00:00:00 2001
From: Aaron Jensen <aaronjensen@gmail.com>
Date: Sun, 4 Feb 2018 22:52:48 -0800
Subject: [PATCH] Show initial buffer immediately upon frame creation from
server
---
lisp/server.el | 85 ++++++++++++++++++++++++++++++++--------------------------
1 file changed, 47 insertions(+), 38 deletions(-)
diff --git a/lisp/server.el b/lisp/server.el
index ac0d701851..f7766a0253 100644
--- a/lisp/server.el
+++ b/lisp/server.el
@@ -1229,28 +1229,29 @@ server-execute-continuation
(or files commands)
(setq use-current-frame t))
- (setq frame
- (cond
- ((and use-current-frame
- (or (eq use-current-frame 'always)
- ;; We can't use the Emacs daemon's
- ;; terminal frame.
- (not (and (daemonp)
- (null (cdr (frame-list)))
- (eq (selected-frame)
- terminal-frame)))))
- (setq tty-name nil tty-type nil)
- (if display (server-select-display display)))
- ((or (and (eq system-type 'windows-nt)
- (daemonp)
- (setq display "w32"))
- (eq tty-name 'window-system))
- (server-create-window-system-frame display nowait proc
- parent-id
- frame-parameters))
- ;; When resuming on a tty, tty-name is nil.
- (tty-name
- (server-create-tty-frame tty-name tty-type proc))))
+ (setq create-frame
+ (lambda ()
+ (cond
+ ((and use-current-frame
+ (or (eq use-current-frame 'always)
+ ;; We can't use the Emacs daemon's
+ ;; terminal frame.
+ (not (and (daemonp)
+ (null (cdr (frame-list)))
+ (eq (selected-frame)
+ terminal-frame)))))
+ (setq tty-name nil tty-type nil)
+ (if display (server-select-display display)))
+ ((or (and (eq system-type 'windows-nt)
+ (daemonp)
+ (setq display "w32"))
+ (eq tty-name 'window-system))
+ (server-create-window-system-frame display nowait proc
+ parent-id
+ frame-parameters))
+ ;; When resuming on a tty, tty-name is nil.
+ (tty-name
+ (server-create-tty-frame tty-name tty-type proc)))))
(process-put
proc 'continuation
@@ -1262,7 +1263,7 @@ server-execute-continuation
(if (and dir (file-directory-p dir))
dir default-directory)))
(server-execute proc files nowait commands
- dontkill frame tty-name)))))
+ dontkill create-frame tty-name)))))
(when (or frame files)
(server-goto-toplevel proc))
@@ -1271,7 +1272,7 @@ server-execute-continuation
;; condition-case
(error (server-return-error proc err))))
-(defun server-execute (proc files nowait commands dontkill frame tty-name)
+(defun server-execute (proc files nowait commands dontkill create-frame tty-name)
;; This is run from timers and process-filters, i.e. "asynchronously".
;; But w.r.t the user, this is not really asynchronous since the timer
;; is run after 0s and the process-filter is run in response to the
@@ -1281,21 +1282,29 @@ server-execute
;; including code that needs to wait.
(with-local-quit
(condition-case err
- (let ((buffers (server-visit-files files proc nowait)))
- (mapc 'funcall (nreverse commands))
+ (let* ((buffers (server-visit-files files proc nowait))
+ ;; If we were told only to open a new client, obey
+ ;; `initial-buffer-choice' if it specifies a file
+ ;; or a function.
+ (initial-buffer (unless (or files commands)
+ (let ((buf
+ (cond ((stringp initial-buffer-choice)
+ (find-file-noselect initial-buffer-choice))
+ ((functionp initial-buffer-choice)
+ (funcall initial-buffer-choice)))))
+ (if (buffer-live-p buf) buf (get-buffer-create "*scratch*")))))
+ ;; Set current buffer so that newly created tty frames
+ ;; show the correct buffer initially.
+ (frame (with-current-buffer (or (car buffers)
+ initial-buffer
+ (current-buffer))
+ (prog1
+ (funcall create-frame)
+ ;; Switch to initial buffer in case the frame was reused.
+ (when initial-buffer
+ (switch-to-buffer initial-buffer 'norecord))))))
- ;; If we were told only to open a new client, obey
- ;; `initial-buffer-choice' if it specifies a file
- ;; or a function.
- (unless (or files commands)
- (let ((buf
- (cond ((stringp initial-buffer-choice)
- (find-file-noselect initial-buffer-choice))
- ((functionp initial-buffer-choice)
- (funcall initial-buffer-choice)))))
- (switch-to-buffer
- (if (buffer-live-p buf) buf (get-buffer-create "*scratch*"))
- 'norecord)))
+ (mapc 'funcall (nreverse commands))
;; Delete the client if necessary.
(cond
--
2.15.1
next prev parent reply other threads:[~2018-02-05 6:56 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-19 14:28 bug#26995: 26.0.50; emacsclient --tty FILE flashes previous frame's buffer before loading FILE Aaron Jensen
2017-05-19 15:30 ` Eli Zaretskii
2017-05-19 15:44 ` Aaron Jensen
2017-05-19 17:27 ` Eli Zaretskii
2018-02-05 6:56 ` Aaron Jensen [this message]
2018-02-09 21:06 ` Aaron Jensen
2018-02-10 10:35 ` Eli Zaretskii
2018-02-10 16:56 ` Aaron Jensen
2018-02-16 15:45 ` Eli Zaretskii
2019-11-01 13:56 ` Eli Zaretskii
2019-11-01 16:27 ` Aaron Jensen
2019-11-01 17:00 ` Eli Zaretskii
2019-11-07 17:15 ` Eli Zaretskii
2022-04-17 19:50 ` Lars Ingebrigtsen
2022-04-17 22:55 ` Aaron Jensen
2022-04-18 9:07 ` Lars Ingebrigtsen
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAHyO48ww-F_MVyyZTfwD7=QzYYsv=88+Z8iRMyPCHeGmV+NQDg@mail.gmail.com' \
--to=aaronjensen@gmail.com \
--cc=26995@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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.