I use emacs-server so that I can set emacsclient as the default texteditor and have it open up new files as buffers rather than new emacs instances.
However, this only works when emacs server is running, so how can I have this run at startup and stay in the background?
Another issue is that if i start emacs, then quit it and restart it, it tells me:
File error: Cannot bind server socket, address already in use
One easy way to start the Emacs daemon is via “Settings > Session and Startup > Application Autostart”. You can also place an init script to place in /etc/init. d/emacsd.
1 Answer. Show activity on this post. Simply use (daemonp) which will return t if emacs is running as a daemon.
Killing Emacs means terminating the Emacs program. To do this, type C-x C-c ( save-buffers-kill-terminal ). A two-character key sequence is used to make it harder to type by accident. If there are any modified file-visiting buffers when you type C-x C-c , Emacs first offers to save these buffers.
Assuming you are using Emacs 23, put
emacs --daemon
in your ~/.xsession
(or wherever you place your startup commands).
This page should tell you all you need to know. An alternative to the suggestion igor made is to make a new script somewhere on you path that contains:
#!/bin/bash
export GDK_NATIVE_WINDOWS=1
exec emacsclient --alternate-editor="" -c "$@"
Assuming you are using GTK.
The alternate-editor="" is a shorthand that tells emacs to start a new server if none is found. This is all from the EmacsWiki page. There are also some fixes for the Connection refused error posted. You should always start there when trying to figure out something about emacs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With