all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Robert Weiner <rsw@gnu.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: martin rudalics <rudalics@gmx.at>, emacs-devel <emacs-devel@gnu.org>
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	[thread overview]
Message-ID: <CA+OMD9jCLLT2sBJVMUyX6CDZZRHQHSH8wsKCYWu5_uQuA5s5ow@mail.gmail.com> (raw)
In-Reply-To: <83o9mvq2l3.fsf@gnu.org>

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

On Mon, Dec 18, 2017 at 2:05 PM, Eli Zaretskii <eliz@gnu.org> 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.
>

​Ok, 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)))))))

[-- Attachment #2: Type: text/html, Size: 8133 bytes --]

  reply	other threads:[~2017-12-18 19:19 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-17 17:28 display-until.el - Display a window or frame topmost in the frame stack until a condition or timeout occurs Robert Weiner
2017-12-17 18:13 ` martin rudalics
2017-12-17 18:46   ` Robert Weiner
2017-12-18  7:26     ` martin rudalics
2017-12-18 16:10       ` Eli Zaretskii
2017-12-18 18:17         ` Robert Weiner
2017-12-18 19:05           ` Eli Zaretskii
2017-12-18 19:19             ` Robert Weiner [this message]
2017-12-19 17:05               ` Eli Zaretskii
2018-01-02 17:36                 ` Robert Weiner
2017-12-20  8:54       ` martin rudalics
2017-12-20 13:44         ` Robert Weiner
2018-01-02 17:38         ` Robert Weiner
2018-01-07 16:08           ` martin rudalics
2018-01-16 17:06             ` Robert Weiner
2018-01-19 18:55         ` martin rudalics
2018-01-20  5:12           ` Noam Postavsky
2018-01-20 10:34             ` martin rudalics

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=CA+OMD9jCLLT2sBJVMUyX6CDZZRHQHSH8wsKCYWu5_uQuA5s5ow@mail.gmail.com \
    --to=rsw@gnu.org \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=rswgnu@gmail.com \
    --cc=rudalics@gmx.at \
    /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.