Is there a way to designate a specific frame in which files opened with emacsclient will appear?

I have one monitor that is dedicated to a fullscreen Emacs frame. I do most of my editing in that monitor, but from time to time I will open a second frame on another monitor temporarily. I want to ensure that every time I open a file using emacsclient, it gets sent to my fullscreen frame and doesn't end up on any other frames that might be open.


The ideal workflow would be that my initial emacs frame gets tagged as the recipient of all emacsclient requests, and the rest is automatic. I always use the initial frame as my primary emacs frame, and other frames come and go as needed.

  • Which operating system are you running? Answers may vary if your window system is X, Windows, Mac OS. Oct 22, 2014 at 5:01
  • @purple_arrows Typically I am on Linux, but I also use Emacs on Mac and Windows. Also, I would like to be able to send the file to a specific frame if possible, not just a specific display.
    – nispio
    Oct 22, 2014 at 15:05
  • It'll take me a while to get back to an answer that (fingers crossed) works cross platforms. server-select-display does the work of selecting the frame to use, and unfortunately it doesn't offer any hooks to customize. Oct 22, 2014 at 18:49

2 Answers 2


If your windowing system is X and your monitors are configured as separate screens, you can pass the appropriate DISPLAY value (e.g. :0.0 or :0.1) to emacsclient with the -d option. That's kind of a big "if".

  • I am using X, and -d :0.0 works fine, but for some reason -d :0.1 gives an error: Display :0.1 can't be opened.
    – nispio
    Oct 22, 2014 at 15:01
  • Your monitors may be set up as one big screen, as opposed to two separate screens. You can tell if you can drag an (X) window a/k/a (Emacs) frame from one monitor to the other - if that's the case, then this solution won't work for you. Oct 22, 2014 at 18:42
  • You are right. This won't work for me, because my monitors are configured as a single display.
    – nispio
    Oct 22, 2014 at 20:58

I have some success with the following command:

emacsclient --eval "(select-frame (car (frames-on-display-list)))"; sleep 1s; emacsclient -n file.txt

The lisp code selects the first frame. To select the second one you should replace car with cadr. But I have not found a way to know which frame is the first ;)



  • The sleep shouldn't be neccesary, because emacsclient only returns when eval is done. Jan 14, 2017 at 12:27

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.