Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I set the port that the Emacs Server uses?

I use Emacs to do most of my development work, I'd like to be able to connect to the Emacs server running on my office workstation from home. I connect to my office network over a VPN, I think this is mostly safe.

Anyway, I have a script that copies the server authentication file out, but it looks like the port changes every time. Our VPN is pretty locked down, I need to tell our sysadmin what ports I want open to which machines.

Is there a way to set the port that the Emacs server listens on?

like image 883
Miles Avatar asked Dec 11 '09 22:12

Miles


2 Answers

Looks like this is now fixed. I'm using Emacs 24.3.1 and there is now a variable server-port:

C-h v server-port RET

gives the following documentation:

Documentation:
The port number that the server process should listen on.
This variable only takes effect when the Emacs server is using
TCP instead of local sockets.  A nil value means to use a random
port number.

You can customize this variable.

This variable was introduced, or its default value was changed, in
version 24.1 of Emacs.

so a (setq server-port 12345) in your init file should do the trick.

like image 71
Craig Waddington Avatar answered Oct 13 '22 05:10

Craig Waddington


Someone posted a small patch to allow customizing the server port to the Emacs Bugs list in September 2008. However, the patch didn't make it into Emacs 23.1 nor does it appear in CVS Emacs as of yet. Your best bet for now might be to patch your version of server.el locally.

like image 25
Emerick Rogul Avatar answered Oct 13 '22 03:10

Emerick Rogul