6

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.

Edit:

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. – purple_arrows Oct 22 '14 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 '14 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. – purple_arrows Oct 22 '14 at 18:49
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 '14 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. – purple_arrows Oct 22 '14 at 18:42
  • You are right. This won't work for me, because my monitors are configured as a single display. – nispio Oct 22 '14 at 20:58
2

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 ;)

Bests,

Jacek

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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