Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to start emacs server only if it is not started?

I'd like to use emacsclient to edit emails in Mutt.

I added this in .emacs

(server-start)

And in .muttrc I added

set editor="emacsclient -nw %s"

It seems they work. When I start a second Emacs, it complains there is already a server running so it issues errors. How to make sure to do (server-start) only if the server isn't already started?

Thanks

like image 385
Meng Lu Avatar asked Apr 06 '11 17:04

Meng Lu


People also ask

How do I know if my Emacs server is running?

In emacs check the value of server-socket-dir . Check if there are some files in this directory. If does, then the server is running.

How do I run Emacs client?

The simplest way to use the emacsclient program is to run the shell command ' emacsclient file ', where file is a file name. This connects to an Emacs server, and tells that Emacs process to visit file in one of its existing frames—either a graphical frame, or one in a text terminal (see Frames and Graphical Displays).


1 Answers

This code starts the server only if it's not running:

(load "server") (unless (server-running-p) (server-start)) 
like image 179
Philipp Avatar answered Oct 20 '22 06:10

Philipp