aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2019-05-03 09:49:38 -0400
committerStefan Monnier2019-05-03 09:49:38 -0400
commitb663c8372495eb98eec15fea463635f4a4da2fad (patch)
tree9d86d02638999fd9a10954d161ec9fba5a187fc9
parentd5497ec3096b3ff42fd1028b5a677cafa6386712 (diff)
downloademacs-b663c8372495eb98eec15fea463635f4a4da2fad.tar.gz
emacs-b663c8372495eb98eec15fea463635f4a4da2fad.zip
* lisp/server.el: Cosmetic changes
Remove redundant :group args. (server-temp-file-regexp): Fix ^$ to \`\'.
-rw-r--r--lisp/server.el53
1 files changed, 24 insertions, 29 deletions
diff --git a/lisp/server.el b/lisp/server.el
index 1e5c57a1c52..d8c7c313ef1 100644
--- a/lisp/server.el
+++ b/lisp/server.el
@@ -96,7 +96,6 @@
96 (unless load-in-progress 96 (unless load-in-progress
97 (message "Local sockets unsupported, using TCP sockets"))) 97 (message "Local sockets unsupported, using TCP sockets")))
98 (set-default sym val)) 98 (set-default sym val))
99 :group 'server
100 :type 'boolean 99 :type 'boolean
101 :version "22.1") 100 :version "22.1")
102 101
@@ -108,7 +107,6 @@ DO NOT give this a non-nil value unless you know what you are doing!
108On unsecured networks, accepting remote connections is very dangerous, 107On unsecured networks, accepting remote connections is very dangerous,
109because server-client communication (including session authentication) 108because server-client communication (including session authentication)
110is not encrypted." 109is not encrypted."
111 :group 'server
112 :type '(choice 110 :type '(choice
113 (string :tag "Name or IP address") 111 (string :tag "Name or IP address")
114 (const :tag "Local" nil)) 112 (const :tag "Local" nil))
@@ -121,7 +119,6 @@ is not encrypted."
121This variable only takes effect when the Emacs server is using 119This variable only takes effect when the Emacs server is using
122TCP instead of local sockets. A nil value means to use a random 120TCP instead of local sockets. A nil value means to use a random
123port number." 121port number."
124 :group 'server
125 :type '(choice 122 :type '(choice
126 (string :tag "Port number") 123 (string :tag "Port number")
127 (const :tag "Random" nil)) 124 (const :tag "Random" nil))
@@ -138,7 +135,6 @@ NOTE: On FAT32 filesystems, directories are not secure;
138files can be read and modified by any user or process. 135files can be read and modified by any user or process.
139It is strongly suggested to set `server-auth-dir' to a 136It is strongly suggested to set `server-auth-dir' to a
140directory residing in a NTFS partition instead." 137directory residing in a NTFS partition instead."
141 :group 'server
142 :type 'directory 138 :type 'directory
143 :version "22.1") 139 :version "22.1")
144;;;###autoload 140;;;###autoload
@@ -166,7 +162,6 @@ communications are unencrypted, still apply.
166The key must consist of 64 ASCII printable characters except for 162The key must consist of 64 ASCII printable characters except for
167space (this means characters from ! to ~; or from code 33 to 163space (this means characters from ! to ~; or from code 33 to
168126). You can use \\[server-generate-key] to get a random key." 164126). You can use \\[server-generate-key] to get a random key."
169 :group 'server
170 :type '(choice 165 :type '(choice
171 (const :tag "Random" nil) 166 (const :tag "Random" nil)
172 (string :tag "Password")) 167 (string :tag "Password"))
@@ -174,30 +169,25 @@ space (this means characters from ! to ~; or from code 33 to
174 169
175(defcustom server-raise-frame t 170(defcustom server-raise-frame t
176 "If non-nil, raise frame when switching to a buffer." 171 "If non-nil, raise frame when switching to a buffer."
177 :group 'server
178 :type 'boolean 172 :type 'boolean
179 :version "22.1") 173 :version "22.1")
180 174
181(defcustom server-visit-hook nil 175(defcustom server-visit-hook nil
182 "Hook run when visiting a file for the Emacs server." 176 "Hook run when visiting a file for the Emacs server."
183 :group 'server
184 :type 'hook) 177 :type 'hook)
185 178
186(defcustom server-switch-hook nil 179(defcustom server-switch-hook nil
187 "Hook run when switching to a buffer for the Emacs server." 180 "Hook run when switching to a buffer for the Emacs server."
188 :group 'server
189 :type 'hook) 181 :type 'hook)
190 182
191(defcustom server-after-make-frame-hook nil 183(defcustom server-after-make-frame-hook nil
192 "Hook run when the Emacs server creates a client frame. 184 "Hook run when the Emacs server creates a client frame.
193The created frame is selected when the hook is called." 185The created frame is selected when the hook is called."
194 :group 'server
195 :type 'hook 186 :type 'hook
196 :version "27.1") 187 :version "27.1")
197 188
198(defcustom server-done-hook nil 189(defcustom server-done-hook nil
199 "Hook run when done editing a buffer for the Emacs server." 190 "Hook run when done editing a buffer for the Emacs server."
200 :group 'server
201 :type 'hook) 191 :type 'hook)
202 192
203(defvar server-process nil 193(defvar server-process nil
@@ -223,7 +213,6 @@ If it is a frame, use the frame's selected window.
223 213
224It is not meaningful to set this to a specific frame or window with Custom. 214It is not meaningful to set this to a specific frame or window with Custom.
225Only programs can do so." 215Only programs can do so."
226 :group 'server
227 :version "22.1" 216 :version "22.1"
228 :type '(choice (const :tag "Use selected window" 217 :type '(choice (const :tag "Use selected window"
229 :match (lambda (widget value) 218 :match (lambda (widget value)
@@ -233,11 +222,10 @@ Only programs can do so."
233 (function-item :tag "Use pop-to-buffer" pop-to-buffer) 222 (function-item :tag "Use pop-to-buffer" pop-to-buffer)
234 (function :tag "Other function"))) 223 (function :tag "Other function")))
235 224
236(defcustom server-temp-file-regexp "^/tmp/Re\\|/draft$" 225(defcustom server-temp-file-regexp "\\`/tmp/Re\\|/draft\\'"
237 "Regexp matching names of temporary files. 226 "Regexp matching names of temporary files.
238These are deleted and reused after each edit by the programs that 227These are deleted and reused after each edit by the programs that
239invoke the Emacs server." 228invoke the Emacs server."
240 :group 'server
241 :type 'regexp) 229 :type 'regexp)
242 230
243(defcustom server-kill-new-buffers t 231(defcustom server-kill-new-buffers t
@@ -248,7 +236,6 @@ it with the Emacs server. If nil, kill only buffers as specified by
248Please note that only buffers that still have a client are killed, 236Please note that only buffers that still have a client are killed,
249i.e. buffers visited with \"emacsclient --no-wait\" are never killed 237i.e. buffers visited with \"emacsclient --no-wait\" are never killed
250in this way." 238in this way."
251 :group 'server
252 :type 'boolean 239 :type 'boolean
253 :version "21.1") 240 :version "21.1")
254 241
@@ -278,7 +265,6 @@ If this is an absolute file name, it specifies where the socket
278file will be created. To have emacsclient connect to the same 265file will be created. To have emacsclient connect to the same
279socket, use the \"-s\" switch for local non-TCP sockets, and 266socket, use the \"-s\" switch for local non-TCP sockets, and
280the \"-f\" switch otherwise." 267the \"-f\" switch otherwise."
281 :group 'server
282 :type 'string 268 :type 'string
283 :version "23.1") 269 :version "23.1")
284 270
@@ -381,7 +367,7 @@ Updates `server-clients'."
381 367
382 (server-log "Deleted" proc)))) 368 (server-log "Deleted" proc))))
383 369
384(defvar server-log-time-function 'current-time-string 370(defvar server-log-time-function #'current-time-string
385 "Function to generate timestamps for `server-buffer'.") 371 "Function to generate timestamps for `server-buffer'.")
386 372
387(defconst server-buffer " *server*" 373(defconst server-buffer " *server*"
@@ -549,6 +535,16 @@ Creates the directory if necessary and makes sure:
549 (cl-letf (((default-file-modes) ?\700)) (make-directory dir t)) 535 (cl-letf (((default-file-modes) ?\700)) (make-directory dir t))
550 (setq attrs (file-attributes dir 'integer))) 536 (setq attrs (file-attributes dir 'integer)))
551 537
538 (let ((olddir (or (getenv "TMPDIR") "/tmp")))
539 (when (and (equal dir (format "%s/emacs" (getenv "XDG_RUNTIME_DIR")))
540 (file-writable-p olddir))
541 (let ((link (format "%s/emacs%d" olddir (user-uid))))
542 (unless (file-directory-p link)
543 ;; We're using the new location, so try and setup a symlink from
544 ;; the old location, in case we want to use an old emacsclient.
545 ;; FIXME: Check that it's safe to use!
546 (make-symbolic-link dir link t)))))
547
552 ;; Check that it's safe for use. 548 ;; Check that it's safe for use.
553 (let* ((uid (file-attribute-user-id attrs)) 549 (let* ((uid (file-attribute-user-id attrs))
554 (w32 (eq system-type 'windows-nt)) 550 (w32 (eq system-type 'windows-nt))
@@ -684,16 +680,16 @@ server or call `\\[server-force-delete]' to forcibly disconnect it."))
684 (when server-process 680 (when server-process
685 (server-log (message "Restarting server"))) 681 (server-log (message "Restarting server")))
686 (cl-letf (((default-file-modes) ?\700)) 682 (cl-letf (((default-file-modes) ?\700))
687 (add-hook 'suspend-tty-functions 'server-handle-suspend-tty) 683 (add-hook 'suspend-tty-functions #'server-handle-suspend-tty)
688 (add-hook 'delete-frame-functions 'server-handle-delete-frame) 684 (add-hook 'delete-frame-functions #'server-handle-delete-frame)
689 (add-hook 'kill-emacs-query-functions 685 (add-hook 'kill-emacs-query-functions
690 'server-kill-emacs-query-function) 686 #'server-kill-emacs-query-function)
691 ;; We put server's kill-emacs-hook after the others, so that 687 ;; We put server's kill-emacs-hook after the others, so that
692 ;; frames are not deleted too early, because doing that 688 ;; frames are not deleted too early, because doing that
693 ;; would severely degrade our abilities to communicate with 689 ;; would severely degrade our abilities to communicate with
694 ;; the user, while some hooks may wish to ask the user 690 ;; the user, while some hooks may wish to ask the user
695 ;; questions (e.g., desktop-kill). 691 ;; questions (e.g., desktop-kill).
696 (add-hook 'kill-emacs-hook 'server-force-stop t) ;Cleanup upon exit. 692 (add-hook 'kill-emacs-hook #'server-force-stop t) ;Cleanup upon exit.
697 (setq server-process 693 (setq server-process
698 (apply #'make-network-process 694 (apply #'make-network-process
699 :name server-name 695 :name server-name
@@ -792,7 +788,6 @@ Server mode runs a process that accepts commands from the
792`emacsclient' program. See Info node `Emacs server' and 788`emacsclient' program. See Info node `Emacs server' and
793`server-start' for details." 789`server-start' for details."
794 :global t 790 :global t
795 :group 'server
796 :version "22.1" 791 :version "22.1"
797 ;; Fixme: Should this check for an existing server socket and do 792 ;; Fixme: Should this check for an existing server socket and do
798 ;; nothing if there is one (for multiple Emacs sessions)? 793 ;; nothing if there is one (for multiple Emacs sessions)?
@@ -1118,7 +1113,7 @@ The following commands are accepted by the client:
1118 ;; Remove this line from STRING. 1113 ;; Remove this line from STRING.
1119 (setq string (substring string (match-end 0))) 1114 (setq string (substring string (match-end 0)))
1120 (setq args-left 1115 (setq args-left
1121 (mapcar 'server-unquote-arg (split-string request " " t))) 1116 (mapcar #'server-unquote-arg (split-string request " " t)))
1122 (while args-left 1117 (while args-left
1123 (pcase (pop args-left) 1118 (pcase (pop args-left)
1124 ;; -version CLIENT-VERSION: obsolete at birth. 1119 ;; -version CLIENT-VERSION: obsolete at birth.
@@ -1341,7 +1336,7 @@ The following commands are accepted by the client:
1341 (when initial-buffer 1336 (when initial-buffer
1342 (switch-to-buffer initial-buffer 'norecord)))))) 1337 (switch-to-buffer initial-buffer 'norecord))))))
1343 1338
1344 (mapc 'funcall (nreverse commands)) 1339 (mapc #'funcall (nreverse commands))
1345 1340
1346 ;; Delete the client if necessary. 1341 ;; Delete the client if necessary.
1347 (cond 1342 (cond
@@ -1441,7 +1436,7 @@ so don't mark these buffers specially, just visit them normally."
1441 (run-hooks 'post-command-hook)) 1436 (run-hooks 'post-command-hook))
1442 (unless nowait 1437 (unless nowait
1443 ;; When the buffer is killed, inform the clients. 1438 ;; When the buffer is killed, inform the clients.
1444 (add-hook 'kill-buffer-hook 'server-kill-buffer nil t) 1439 (add-hook 'kill-buffer-hook #'server-kill-buffer nil t)
1445 (push proc server-buffer-clients)) 1440 (push proc server-buffer-clients))
1446 (push (current-buffer) client-record))) 1441 (push (current-buffer) client-record)))
1447 (unless nowait 1442 (unless nowait
@@ -1552,8 +1547,8 @@ specifically for the clients and did not exist before their request for it."
1552 "Ask before exiting Emacs if it has live clients." 1547 "Ask before exiting Emacs if it has live clients."
1553 (or (not (let (live-client) 1548 (or (not (let (live-client)
1554 (dolist (proc server-clients) 1549 (dolist (proc server-clients)
1555 (when (memq t (mapcar 'buffer-live-p (process-get 1550 (when (memq t (mapcar #'buffer-live-p
1556 proc 'buffers))) 1551 (process-get proc 'buffers)))
1557 (setq live-client t))) 1552 (setq live-client t)))
1558 live-client)) 1553 live-client))
1559 (yes-or-no-p "This Emacs session has clients; exit anyway? "))) 1554 (yes-or-no-p "This Emacs session has clients; exit anyway? ")))
@@ -1589,7 +1584,7 @@ starts server process and that is all. Invoked by \\[server-edit]."
1589 (not server-process) 1584 (not server-process)
1590 (memq (process-status server-process) '(signal exit))) 1585 (memq (process-status server-process) '(signal exit)))
1591 (server-mode 1)) 1586 (server-mode 1))
1592 (server-clients (apply 'server-switch-buffer (server-done))) 1587 (server-clients (apply #'server-switch-buffer (server-done)))
1593 (t (message "No server editing buffers exist")))) 1588 (t (message "No server editing buffers exist"))))
1594 1589
1595(defun server-switch-buffer (&optional next-buffer killed-one filepos) 1590(defun server-switch-buffer (&optional next-buffer killed-one filepos)
@@ -1622,7 +1617,7 @@ be a cons cell (LINENUMBER . COLUMNNUMBER)."
1622 (if (not (buffer-live-p next-buffer)) 1617 (if (not (buffer-live-p next-buffer))
1623 ;; If NEXT-BUFFER is a dead buffer, remove the server records for it 1618 ;; If NEXT-BUFFER is a dead buffer, remove the server records for it
1624 ;; and try the next surviving server buffer. 1619 ;; and try the next surviving server buffer.
1625 (apply 'server-switch-buffer (server-buffer-done next-buffer)) 1620 (apply #'server-switch-buffer (server-buffer-done next-buffer))
1626 ;; OK, we know next-buffer is live, let's display and select it. 1621 ;; OK, we know next-buffer is live, let's display and select it.
1627 (if (functionp server-window) 1622 (if (functionp server-window)
1628 (funcall server-window next-buffer) 1623 (funcall server-window next-buffer)
@@ -1701,7 +1696,7 @@ only these files will be asked to be saved."
1701 (save-current-buffer 1696 (save-current-buffer
1702 (dolist (buffer (buffer-list)) 1697 (dolist (buffer (buffer-list))
1703 (set-buffer buffer) 1698 (set-buffer buffer)
1704 (remove-hook 'kill-buffer-hook 'server-kill-buffer t))) 1699 (remove-hook 'kill-buffer-hook #'server-kill-buffer t)))
1705 ;; continue standard unloading 1700 ;; continue standard unloading
1706 nil) 1701 nil)
1707 1702