emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: display-until.el - Display a window or frame topmost in the frame st


From: Robert Weiner
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

On Mon, Dec 18, 2017 at 2:05 PM, Eli Zaretskii <address@hidden> 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)))))))


reply via email to

[Prev in Thread] Current Thread [Next in Thread]