- (let ((umask (default-file-modes)))
- (unwind-protect
- (progn
- (set-default-file-modes ?\700)
- (setq server-process
- (make-network-process
- :name "server" :family 'local :server t :noquery t
- :service server-socket-name
- :sentinel 'server-sentinel :filter 'server-process-filter
- ;; We must receive file names without being decoded.
- ;; Those are decoded by server-process-filter according
- ;; to file-name-coding-system.
- :coding 'raw-text)))
- (set-default-file-modes umask)))))
+ (letf (((default-file-modes) ?\700))
+ (setq server-process
+ (make-network-process
+ :name "server" :family 'local :server t :noquery t
+ :service (expand-file-name server-name server-socket-dir)
+ :sentinel 'server-sentinel :filter 'server-process-filter
+ ;; We must receive file names without being decoded.
+ ;; Those are decoded by server-process-filter according
+ ;; to file-name-coding-system.
+ :coding 'raw-text)))))
+
+;;;###autoload
+(define-minor-mode server-mode
+ "Toggle Server mode.
+With ARG, turn Server mode on if ARG is positive, off otherwise.
+Server mode runs a process that accepts commands from the
+`emacsclient' program. See `server-start' and Info node `Emacs server'."
+ :global t
+ :group 'server
+ :version "22.1"
+ ;; Fixme: Should this check for an existing server socket and do
+ ;; nothing if there is one (for multiple Emacs sessions)?
+ (server-start (not server-mode)))