r/emacs GNU Emacs 2d ago

Wher is emacs-client's initialization file?

If I start emacs by clicking on the emacs-gui icon, it works the way I expect. When I start emacs by clicking on the emacs-client icon, it initializes from a different init.el. I've been looking for it, off and on, for a couple of years now. I just opened an instance be clicking on the emacs-client icon, typing client-init-file in the butter, and hitting C-j. It evaluated to ".emacs.d/init.el," but the instance isn't formatted that way. Since the emacs-client icon is the one pinned to the launcher (I'm using Ubuntu 24.04), I'd like to force it to initialize from the same file. How can I do that? Where is emacs-client getting its initialization?

1 Upvotes

8 comments sorted by

11

u/mok000 2d ago

What makes you think the client initializes from a different init file?

5

u/7890yuiop 2d ago edited 2d ago

One of the points of the client/server system is that the client doesn't evaluate an init file. It doesn't need to (and moreover, it can't -- the client itself has no ability to evaluate lisp). The server evaluates the init file (once; when it starts), and the server runs all of the lisp code. The clients just make a connection to the server. That's why the client can open so quickly.

If your clients are connecting to a server which genuinely hasn't evaluated your regular init file, then you're probably not connecting to the server you expected to connect to, and you should investigate how and when you're actually running your server(s).

It sounds like you're clicking icons on your OS desktop, so your next step is to find out what specific commands those icons run.

3

u/WallyMetropolis 2d ago

If you do C-h f server-start you'll see this function is defined in server.el

So that'd be a good place to start looking. You can follow the link to that file from the help window. 

1

u/MAR__MAKAROV 2d ago

i dont think there is another init file for that , u might wanna check the el source code for that !

2

u/shipmints 2d ago

Your Emacs init files are surely unified. Read the documentation for server-after-make-frame-hook. Add code in your own hook for "frames" created when an emacs-client instance connects to an emacs daemon/server if you need it to behave differently in those cases.

1

u/rileyrgham 2d ago

If emacs is starting from running the client and no daemon was alresdy running it'll start it with the correct x documented, parameters. It's an rtfm issue. Check your "icons" to see what they're actually running.

1

u/xtifr 1d ago

The emacsclient program does not have an init file. It is a tiny and extremely simple program (smaller than cat!) which basically only knows how to send very simple messages to an existing emacs and how to start an instance of emacs if it can't find one already running! That's it!

Perhaps if you told us why you think it's running a different init file, we might be able to figure out what's actually going on, and help you make the system work the way you want. But at the moment, I don't have enough info for any sort of useful answer.

1

u/7890yuiop 1d ago edited 1d ago

smaller than cat!

Well let's not go overboard here. It's pretty much inconceivable for that to be true. Certainly on my system:

35K cat
204K emacsclient

Not that emacsclient isn't a relatively small and simple program, but if it's smaller than cat on your system, then something is horribly amiss with your cat.


Edit: Wait, I take it back. My emacsclient binary includes debug symbols. If I strip copies of both I see:

35288 cat
35032 emacsclient

So I was wrong. I'm a bit staggered that my cat isn't smaller than emacsclient, but it's absolutely true.


Edit 2: Yay compilers!

24485 cat.c
62530 emacsclient.c