3

I have emacs running as a daemon (using launchctl), and I can use emacsclient --socket-name=socket -n -r -a '' and open a frame just fine. But if I run it again (say, to open some file), it opens another frame. Am I wrong in assuming that -r should make it open the buffer for that file in the already existing frame?

This is using emacs 29.1 on an M2 mac, if that's useful context.

EDIT: I've tried using builds from https://emacsformacos.com, Homebrew, and building directly from source, and I get the same result from all three. The -r option to emacsclient doesn't reuse frames. What the eff?

4
  • It should work the way you expected. It's not starting a new server each time, is it? Each new frame is part of the same single Emacs instance? Commented Oct 27, 2023 at 0:23
  • I mean, I don't THINK it's starting a new server. I don't see a second instance of Emacs in the process list, and I don't start the server from my init.el. Commented Oct 27, 2023 at 1:26
  • 1
    Yeah, I can see common buffers in both, and typing in one frame shows the text in the other frame, so I'm confident that another instance of Emacs isn't starting. Commented Oct 27, 2023 at 15:16
  • See mail.gnu.org/archive/html/bug-gnu-emacs/2021-12/msg01648.html as I don't know how to lookup Emacs bugs I have no idea if this was meant to have been fixed. In my 29.4 this is still an issue. Commented Aug 25, 2024 at 7:14

2 Answers 2

3

I don't know why this works, but removing the -r option makes emacsclient reuse the frame as I expect.

1
  • This holds true for me as well (Emacs 29.3 from emacsformacosx.com by way of Homebrew, macOS Sonoma 14.4.1). Unfortunately the first emacsclient invocation opens a TTY frame (as though I used -nw) so either I have to remember to pass -c on my first invocation of the day or I will have to find a scripted way to detect whether I have any GUI frames open. Commented Apr 10, 2024 at 20:14
-1

You can see the switches by typing

emacsclient --help

in a terminal. Doing this, you'll see the following, along with several other helpful options:

-r, --reuse-frame       Create a new frame if none exists, otherwise
                        use the current Emacs frame
1
  • Yes that is what the documentation says - but not working on macOS M1 - I always get a new frame. NB -r produces an error --reuse-frame was needed to run. Emacs 29.4 Commented Aug 25, 2024 at 7:09

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.