Subject: bug#854: Server port customisation

From: Peter Oliver <[email-masked]>
Date: Mon, 1 Sep 2008 19:28:06 +0100 (BST)

Attached is a patch that adds a customisation option to force the Emacs 
server to listen on a particular port.  This makes it simple to set up a 
firewall rule or port forwarding to allow incoming connections from a 
remote emacsclient.

-- 
Peter Oliver

Index: server.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/server.el,v
retrieving revision 1.166
diff -u -r1.166 server.el
--- server.el	6 May 2008 07:57:49 -0000	1.166
+++ server.el	31 Aug 2008 14:30:51 -0000
@@ -111,6 +111,15 @@
   :version "22.1")
 (put 'server-host 'risky-local-variable t)
 
+(defcustom server-port nil
+  "The port number that the server process should listen on."
+  :group 'server
+  :type '(choice
+          (string :tag "Port number")
+          (const :tag "Random" nil))
+  :version "22.1")
+(put 'server-port 'risky-local-variable t)
+
 (defcustom server-auth-dir (concat user-emacs-directory "server/")
   "Directory for server authentication files."
   :group 'server
@@ -504,7 +513,7 @@
 		       ;; The other args depend on the kind of socket used.
 		       (if server-use-tcp
 			   (list :family nil
-				 :service t
+				 :service (or server-port t)
 				 :host (or server-host 'local)
 				 :plist '(:authenticated nil))
 			 (list :family 'local