;;; server.el --- Lisp code for GNU Emacs running as server process -*- lexical-binding: t -*-
-;; Copyright (C) 1986-1987, 1992, 1994-2013 Free Software Foundation,
+;; Copyright (C) 1986-1987, 1992, 1994-2014 Free Software Foundation,
;; Inc.
;; Author: William Sommerfeld <wesommer@athena.mit.edu>
-;; Maintainer: FSF
+;; Maintainer: emacs-devel@gnu.org
;; Keywords: processes
;; Changes by peck@sun.com and by rms.
"The name or IP address to use as host address of the server process.
If set, the server accepts remote connections; otherwise it is local.
-DO NOT give this a non-nil value unless you know what you are
-doing! On unsecured networks, accepting remote connections is
-very dangerous, because server-client communication (including
-session authentication) is not encrypted."
+DO NOT give this a non-nil value unless you know what you are doing!
+On unsecured networks, accepting remote connections is very dangerous,
+because server-client communication (including session authentication)
+is not encrypted."
:group 'server
:type '(choice
(string :tag "Name or IP address")
(cl-letf (((default-file-modes) ?\700))
(add-hook 'suspend-tty-functions 'server-handle-suspend-tty)
(add-hook 'delete-frame-functions 'server-handle-delete-frame)
- (add-hook 'kill-buffer-query-functions
- 'server-kill-buffer-query-function)
(add-hook 'kill-emacs-query-functions
'server-kill-emacs-query-function)
(add-hook 'kill-emacs-hook 'server-force-stop) ;Cleanup upon exit.
(save-buffer)))
(server-buffer-done (current-buffer))))
-;; Ask before killing a server buffer.
-;; It was suggested to release its client instead,
-;; but I think that is dangerous--the client would proceed
-;; using whatever is on disk in that file. -- rms.
-(defun server-kill-buffer-query-function ()
- "Ask before killing a server buffer."
- (or (not server-buffer-clients)
- (let ((res t))
- (dolist (proc server-buffer-clients)
- (when (and (memq proc server-clients)
- (eq (process-status proc) 'open))
- (setq res nil)))
- res)
- (yes-or-no-p (format "Buffer `%s' still has clients; kill it? "
- (buffer-name (current-buffer))))))
-
(defun server-kill-emacs-query-function ()
"Ask before exiting Emacs if it has live clients."
(or (not server-clients)
(setq next-buffer (car (process-get proc 'buffers))))
(setq rest (cdr rest)))))
(and next-buffer (server-switch-buffer next-buffer killed-one))
- (unless (or next-buffer killed-one (window-dedicated-p (selected-window)))
+ (unless (or next-buffer killed-one (window-dedicated-p))
;; (switch-to-buffer (other-buffer))
(message "No server buffers remain to edit")))
(if (not (buffer-live-p next-buffer))
(unless (frame-live-p server-window)
(setq server-window (make-frame)))
(select-window (frame-selected-window server-window))))
- (when (window-minibuffer-p (selected-window))
+ (when (window-minibuffer-p)
(select-window (next-window nil 'nomini 0)))
;; Move to a non-dedicated window, if we have one.
- (when (window-dedicated-p (selected-window))
+ (when (window-dedicated-p)
(select-window
(get-window-with-predicate
(lambda (w)
(and (not (window-dedicated-p w))
(equal (frame-terminal (window-frame w))
- (frame-terminal (selected-frame)))))
+ (frame-terminal))))
'nomini 'visible (selected-window))))
(condition-case nil
(switch-to-buffer next-buffer)
;; a minibuffer/dedicated-window (if there's no other).
(error (pop-to-buffer next-buffer)))))))
(when server-raise-frame
- (select-frame-set-input-focus (window-frame (selected-window))))))
+ (select-frame-set-input-focus (window-frame)))))
;;;###autoload
(defun server-save-buffers-kill-terminal (arg)
If emacsclient was started with a list of filenames to edit, then
only these files will be asked to be saved."
- (let ((proc (frame-parameter (selected-frame) 'client)))
+ (let ((proc (frame-parameter nil 'client)))
(cond ((eq proc 'nowait)
;; Nowait frames have no client buffer list.
(if (cdr (frame-list))
(define-key ctl-x-map "#" 'server-edit)
(defun server-unload-function ()
- "Unload the server library."
+ "Unload the Server library."
(server-mode -1)
(substitute-key-definition 'server-edit nil ctl-x-map)
(save-current-buffer
"Contact the Emacs server named SERVER and evaluate FORM there.
Returns the result of the evaluation, or signals an error if it
cannot contact the specified server. For example:
- \(server-eval-at \"server\" '(emacs-pid))
+ (server-eval-at \"server\" '(emacs-pid))
returns the process ID of the Emacs instance running \"server\"."
(let* ((server-dir (if server-use-tcp server-auth-dir server-socket-dir))
(server-file (expand-file-name server server-dir))