(unless load-in-progress
(message "Local sockets unsupported, using TCP sockets")))
(set-default sym val))
- :group 'server
:type 'boolean
:version "22.1")
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")
(const :tag "Local" nil))
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."
- :group 'server
:type '(choice
(string :tag "Port number")
(const :tag "Random" nil))
files can be read and modified by any user or process.
It is strongly suggested to set `server-auth-dir' to a
directory residing in a NTFS partition instead."
- :group 'server
:type 'directory
:version "22.1")
;;;###autoload
The key must consist of 64 ASCII printable characters except for
space (this means characters from ! to ~; or from code 33 to
126). You can use \\[server-generate-key] to get a random key."
- :group 'server
:type '(choice
(const :tag "Random" nil)
(string :tag "Password"))
(defcustom server-raise-frame t
"If non-nil, raise frame when switching to a buffer."
- :group 'server
:type 'boolean
:version "22.1")
(defcustom server-visit-hook nil
"Hook run when visiting a file for the Emacs server."
- :group 'server
:type 'hook)
(defcustom server-switch-hook nil
"Hook run when switching to a buffer for the Emacs server."
- :group 'server
:type 'hook)
(defcustom server-after-make-frame-hook nil
"Hook run when the Emacs server creates a client frame.
The created frame is selected when the hook is called."
- :group 'server
:type 'hook
:version "27.1")
(defcustom server-done-hook nil
"Hook run when done editing a buffer for the Emacs server."
- :group 'server
:type 'hook)
(defvar server-process nil
It is not meaningful to set this to a specific frame or window with Custom.
Only programs can do so."
- :group 'server
:version "22.1"
:type '(choice (const :tag "Use selected window"
:match (lambda (widget value)
(function-item :tag "Use pop-to-buffer" pop-to-buffer)
(function :tag "Other function")))
-(defcustom server-temp-file-regexp "^/tmp/Re\\|/draft$"
+(defcustom server-temp-file-regexp "\\`/tmp/Re\\|/draft\\'"
"Regexp matching names of temporary files.
These are deleted and reused after each edit by the programs that
invoke the Emacs server."
- :group 'server
:type 'regexp)
(defcustom server-kill-new-buffers t
Please note that only buffers that still have a client are killed,
i.e. buffers visited with \"emacsclient --no-wait\" are never killed
in this way."
- :group 'server
:type 'boolean
:version "21.1")
file will be created. To have emacsclient connect to the same
socket, use the \"-s\" switch for local non-TCP sockets, and
the \"-f\" switch otherwise."
- :group 'server
:type 'string
:version "23.1")
(server-log "Deleted" proc))))
-(defvar server-log-time-function 'current-time-string
+(defvar server-log-time-function #'current-time-string
"Function to generate timestamps for `server-buffer'.")
(defconst server-buffer " *server*"
(cl-letf (((default-file-modes) ?\700)) (make-directory dir t))
(setq attrs (file-attributes dir 'integer)))
+ (let ((olddir (or (getenv "TMPDIR") "/tmp")))
+ (when (and (equal dir (format "%s/emacs" (getenv "XDG_RUNTIME_DIR")))
+ (file-writable-p olddir))
+ (let ((link (format "%s/emacs%d" olddir (user-uid))))
+ (unless (file-directory-p link)
+ ;; We're using the new location, so try and setup a symlink from
+ ;; the old location, in case we want to use an old emacsclient.
+ ;; FIXME: Check that it's safe to use!
+ (make-symbolic-link dir link t)))))
+
;; Check that it's safe for use.
(let* ((uid (file-attribute-user-id attrs))
(w32 (eq system-type 'windows-nt))
(when server-process
(server-log (message "Restarting server")))
(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 'suspend-tty-functions #'server-handle-suspend-tty)
+ (add-hook 'delete-frame-functions #'server-handle-delete-frame)
(add-hook 'kill-emacs-query-functions
- 'server-kill-emacs-query-function)
+ #'server-kill-emacs-query-function)
;; We put server's kill-emacs-hook after the others, so that
;; frames are not deleted too early, because doing that
;; would severely degrade our abilities to communicate with
;; the user, while some hooks may wish to ask the user
;; questions (e.g., desktop-kill).
- (add-hook 'kill-emacs-hook 'server-force-stop t) ;Cleanup upon exit.
+ (add-hook 'kill-emacs-hook #'server-force-stop t) ;Cleanup upon exit.
(setq server-process
(apply #'make-network-process
:name server-name
`emacsclient' program. See Info node `Emacs server' and
`server-start' for details."
: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)?
;; Remove this line from STRING.
(setq string (substring string (match-end 0)))
(setq args-left
- (mapcar 'server-unquote-arg (split-string request " " t)))
+ (mapcar #'server-unquote-arg (split-string request " " t)))
(while args-left
(pcase (pop args-left)
;; -version CLIENT-VERSION: obsolete at birth.
(when initial-buffer
(switch-to-buffer initial-buffer 'norecord))))))
- (mapc 'funcall (nreverse commands))
+ (mapc #'funcall (nreverse commands))
;; Delete the client if necessary.
(cond
(run-hooks 'post-command-hook))
(unless nowait
;; When the buffer is killed, inform the clients.
- (add-hook 'kill-buffer-hook 'server-kill-buffer nil t)
+ (add-hook 'kill-buffer-hook #'server-kill-buffer nil t)
(push proc server-buffer-clients))
(push (current-buffer) client-record)))
(unless nowait
"Ask before exiting Emacs if it has live clients."
(or (not (let (live-client)
(dolist (proc server-clients)
- (when (memq t (mapcar 'buffer-live-p (process-get
- proc 'buffers)))
+ (when (memq t (mapcar #'buffer-live-p
+ (process-get proc 'buffers)))
(setq live-client t)))
live-client))
(yes-or-no-p "This Emacs session has clients; exit anyway? ")))
(not server-process)
(memq (process-status server-process) '(signal exit)))
(server-mode 1))
- (server-clients (apply 'server-switch-buffer (server-done)))
+ (server-clients (apply #'server-switch-buffer (server-done)))
(t (message "No server editing buffers exist"))))
(defun server-switch-buffer (&optional next-buffer killed-one filepos)
(if (not (buffer-live-p next-buffer))
;; If NEXT-BUFFER is a dead buffer, remove the server records for it
;; and try the next surviving server buffer.
- (apply 'server-switch-buffer (server-buffer-done next-buffer))
+ (apply #'server-switch-buffer (server-buffer-done next-buffer))
;; OK, we know next-buffer is live, let's display and select it.
(if (functionp server-window)
(funcall server-window next-buffer)
(save-current-buffer
(dolist (buffer (buffer-list))
(set-buffer buffer)
- (remove-hook 'kill-buffer-hook 'server-kill-buffer t)))
+ (remove-hook 'kill-buffer-hook #'server-kill-buffer t)))
;; continue standard unloading
nil)