help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: How to get the new frame?


From: martin rudalics
Subject: Re: How to get the new frame?
Date: Tue, 21 Jul 2015 09:00:30 +0200

> Is there a neat way in Lisp code to get at the frame which
> find-file-other-frame just has created?

No.  Also so because `find-file-other-frame' might not have created a
new frame in the first place.  You would have to write a function
returning a list of all windows on all frames together with the buffers
they show and call that function twice, once before and once after
calling `find-file-other-frame'.  If the list returned by the second
call contains a window showing your file and that window is not present
in the list returned by the first call, chances are that you have found
the right window.

> The function itself returns
> (indirectly, via switch-to-buffer-other-frame) the buffer and not the
> frame, just as all the *-other-frame functions.

Indeed.  I suppose something like

(let* ((buffer (find-file-noselect FILENAME))
       (window (display-buffer buffer '((display-buffer-pop-up-frame)))))
  (when (eq (window-buffer window) buffer)
    (window-frame window)))

should be sufficient for your purposes.

martin



reply via email to

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