I am trying to write an Elisp function that will create a new frame and in that new frame open two files split vertically.

I have been unable to find anything about this in the Elisp manual, node Creating Frames

How can I do this?

  • When you say "split vertically" do you mean that the frame is split into two windows side-by-side or one above the other?
    – NickD
    Commented Aug 2, 2020 at 3:05

1 Answer 1


You can try this function:

(defun my/open-files-vert-in-new-frame (file1 file2)
  (interactive "f\nf")
  (select-frame-set-input-focus (make-frame))
  (find-file file1)
  (find-file file2))

The key is select-frame-set-input-focus which makes subsequent functions operating on windows of the new frame and set input focus on it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.