From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Robert Weiner Newsgroups: gmane.emacs.devel Subject: Re: display-until.el - Display a window or frame topmost in the frame stack until a condition or timeout occurs Date: Mon, 18 Dec 2017 14:19:23 -0500 Message-ID: References: <5A36B3B3.9040607@gmx.at> <5A376D9F.7000006@gmx.at> <83tvwoow4a.fsf@gnu.org> <83o9mvq2l3.fsf@gnu.org> Reply-To: rswgnu@gmail.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="089e0828a8fc3475130560a23c7d" X-Trace: blaine.gmane.org 1513625357 5495 195.159.176.226 (18 Dec 2017 19:29:17 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 18 Dec 2017 19:29:17 +0000 (UTC) Cc: martin rudalics , emacs-devel To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Dec 18 20:29:13 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eR167-0000yI-8F for ged-emacs-devel@m.gmane.org; Mon, 18 Dec 2017 20:29:11 +0100 Original-Received: from localhost ([::1]:33561 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eR185-0005iR-Eq for ged-emacs-devel@m.gmane.org; Mon, 18 Dec 2017 14:31:13 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58304) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eR0xH-0003xV-FY for emacs-devel@gnu.org; Mon, 18 Dec 2017 14:20:04 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eR0x9-0003Qm-S7 for emacs-devel@gnu.org; Mon, 18 Dec 2017 14:20:01 -0500 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:43558) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eR0x9-0003Qf-ON for emacs-devel@gnu.org; Mon, 18 Dec 2017 14:19:55 -0500 Original-Received: from mail-qt0-f175.google.com ([209.85.216.175]:40398) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1eR0x9-0004pu-50; Mon, 18 Dec 2017 14:19:55 -0500 Original-Received: by mail-qt0-f175.google.com with SMTP id u42so21373111qte.7; Mon, 18 Dec 2017 11:19:55 -0800 (PST) X-Gm-Message-State: AKGB3mJcOAoGV3vI2iypjYYbO8TYVOSEiJP23I6IJREBFuYo0oAgm4qx UPbQbFg515uQX9tlmQEWlIX40Bfhp5oxgyhIvbE= X-Google-Smtp-Source: ACJfBosEvCidX0LAj+6HS6KujIqPtY5mukEr6d3XMIG51tuBJ9ULHBuPiuF3hFi6AEWTELF/L68NsREz+TWqfSaH7KM= X-Received: by 10.200.19.11 with SMTP id e11mr1187187qtj.62.1513624794590; Mon, 18 Dec 2017 11:19:54 -0800 (PST) Original-Received: by 10.200.55.124 with HTTP; Mon, 18 Dec 2017 11:19:23 -0800 (PST) In-Reply-To: <83o9mvq2l3.fsf@gnu.org> X-Gmail-Original-Message-ID: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:221223 Archived-At: --089e0828a8fc3475130560a23c7d Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Dec 18, 2017 at 2:05 PM, Eli Zaretskii wrote: > > How can an Elisp programmer be sure the frame creation has > > finished without any reference to its creation thread? > > The usual way is to insert > > (sit-for 0 t) > > before the code that needs the frame visible. You can see this, e.g., > in fancy-splash-frame and in some other places. > =E2=80=8BOk, I'll add that. Could you run the tests at the end of the file and see if this version of that function resolves your issues: (defun display-frame-until-condition (frame &optional buffer condition) "Display FRAME topmost with optional BUFFER in its selected window until CONDITION or `display-until-delay' seconds. FRAME may be an existing, even invisible frame, frame name or nil. If nil, the selected frame is used. If FRAME is a string and no live frame with that name is found, a new one with the name and any `display-until-frame-parameters' is created. BUFFER may be an existing buffer or buffer name. After display, FRAME's prior visibility status is restored. FRAME's depth in the frame stacking order is not restored." (unless frame (setq frame (selected-frame))) (when (stringp frame) (setq frame (or (display-until-get-frame-by-name frame) (prog1 (make-frame (cons `(name . ,frame) display-until-frame-parameters)) ;; Wait for frame creation to finish (sit-for 0 t))))) (cond ((not (framep frame)) (error "(display-frame-until): First argument must be a frame, not `%s'" frame)) ((not (frame-live-p frame)) (error "(display-frame-until): First argument must be a live frame, not `%s'" frame)) ((and buffer (not (or (bufferp buffer) (and (stringp buffer) (get-buffer buffer))))) (redisplay t) (error "(display-frame-until): Second argument must be an existing buffer or buffer name, not `%s'" buffer)) (t (let ((frame-visible-flag (frame-visible-p frame))) (select-frame frame) (raise-frame frame) (display-buffer (or buffer (window-buffer)) (cons 'display-buffer-same-window display-until-frame-parameters) frame) ;; Force redisplay or any changes to frame won't be displayed here. (redisplay t) (if condition (display-until-condition-or-timeout condition display-until-delay) ;; Don't use sit-for here because it can be interrupted early. (sleep-for display-until-delay)) (pcase frame-visible-flag ('icon (iconify-frame frame)) ('nil (make-frame-invisible frame))))))) --089e0828a8fc3475130560a23c7d Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Mon, Dec 18, 2= 017 at 2:05 PM, Eli Zaretskii <el= iz@gnu.org> wrot= e:
> How can an Elisp programmer be sure the frame creation has
> finished without any reference to its creation thread?

The usual way is to insert

=C2=A0 (sit-for 0 t)

before the code that needs the frame visible.=C2=A0 You can see this, e.g.,=
in fancy-splash-frame and in some other places.

= =E2=80=8BOk, I'll add that.=C2=A0 Could you run the tests at the end
o= f the file and see if this version of that function resolves
your issues:<= /div>

(defun display-frame-until-condition (frame &= amp;optional buffer condition)
=C2=A0 "Display FRAME topmost with op= tional BUFFER in its selected window until CONDITION or `display-until-dela= y' seconds.

FRAME may be an existing, even invisible frame, f= rame name or
nil.=C2=A0 If nil, the selected frame is used.=C2=A0 If FRAM= E is a string
and no live frame with that name is found, a new one with t= he
name and any `display-until-frame-parameters' is created.

BUFFER may be an existing buffer or buffer name.

After display, F= RAME's prior visibility status is restored.
FRAME's depth in the = frame stacking order is not restored."
=C2=A0 (unless frame
=C2=A0= =C2=A0 (setq frame (selected-frame)))
=C2=A0 (when (stringp frame)
=C2= =A0 =C2=A0 (setq frame (or (display-until-get-frame-by-name frame)
=C2=A0 =C2=A0 (prog1 (make-frame (cons `= (name . ,frame)
=C2=A0 =C2=A0= =C2=A0display-until-frame-parameters))
= =C2=A0 =C2=A0 =C2=A0 ;; Wait for frame creation to finish
=C2=A0 =C2=A0 =C2=A0 (sit-for 0 t)))))
= =C2=A0 (cond ((not (framep frame))
(error "(display-frame-until): First argument must be a frame, not = `%s'"
frame))
((not (frame-live-p frame))
(error "(display-frame-until): First arg= ument must be a live frame, not `%s'"
frame))
((and buf= fer (not (or (bufferp buffer) (and (stringp buffer)
=C2=A0 =C2=A0 (get-buffer buffer)))))
=
(redisplay t)
(error "(display-frame-until): Second argument must be an= existing buffer or buffer name, not `%s'"
buffer))
(t<= /font>
(let ((frame-visible-flag (frame= -visible-p frame)))
=C2=A0 =C2=A0= (select-frame frame)
=C2=A0 =C2= =A0(raise-frame frame)
=C2=A0 = =C2=A0(display-buffer (or buffer (window-buffer))
=C2=A0 =C2=A0(cons 'display-buffer-same-window
display-until-frame-parameters) fr= ame)
=C2=A0 =C2=A0;; Force redisp= lay or any changes to frame won't be displayed here.
=C2=A0 =C2=A0(redisplay t)
=C2=A0 =C2=A0(if condition
=C2=A0 =C2=A0 =C2=A0 =C2=A0(display-until-condition-or-timeou= t condition display-until-delay)
<= font face=3D"monospace, monospace"> = =C2=A0 =C2=A0 =C2=A0;; Don't use sit-for here because it can be interru= pted early.
=C2=A0 =C2=A0 =C2=A0(= sleep-for display-until-delay))
= =C2=A0 =C2=A0(pcase frame-visible-flag
<= /span>=C2=A0 =C2=A0 =C2=A0('icon (iconify-frame frame))
=C2=A0 =C2=A0 =C2=A0('nil=C2=A0 (make-fram= e-invisible frame)))))))

--089e0828a8fc3475130560a23c7d--