Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to keep a persistent emacs-server instance running?

Tags:

emacs

ubuntu

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

like image 393
tobeannounced Avatar asked Dec 16 '10 07:12

tobeannounced


People also ask

How do I enable Emacs daemon?

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.

How can I tell if Emacs daemon is running?

1 Answer. Show activity on this post. Simply use (daemonp) which will return t if emacs is running as a daemon.

How do I stop Emacs from running?

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.


2 Answers

Assuming you are using Emacs 23, put

emacs --daemon

in your ~/.xsession (or wherever you place your startup commands).

like image 190
igor Avatar answered Oct 18 '22 20:10

igor


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.

like image 32
hanDerPeder Avatar answered Oct 18 '22 21:10

hanDerPeder