comparison lisp/server.el @ 7736:8c8410bc0f1b

(server-visit-files): Bind last-nonmenu-event. (server-kill-emacs-query-function): Ignore killed buffers.
author Richard M. Stallman <rms@gnu.org>
date Sat, 28 May 1994 17:22:31 +0000
parents 99a600c67e82
children 69ec123ef310
comparison
equal deleted inserted replaced
7735:7db892210924 7736:8c8410bc0f1b
90 90
91 (defvar server-previous-string "") 91 (defvar server-previous-string "")
92 92
93 (defvar server-clients nil 93 (defvar server-clients nil
94 "List of current server clients. 94 "List of current server clients.
95 Each element is (CLIENTID FILES...) where CLIENTID is a string 95 Each element is (CLIENTID BUFFERS...) where CLIENTID is a string
96 that can be given to the server process to identify a client. 96 that can be given to the server process to identify a client.
97 When a buffer is marked as \"done\", it is removed from this list.") 97 When a buffer is marked as \"done\", it is removed from this list.")
98 98
99 (defvar server-buffer-clients nil 99 (defvar server-buffer-clients nil
100 "List of clientids for clients requesting editing of current buffer.") 100 "List of clientids for clients requesting editing of current buffer.")
195 "When done with a buffer, type \\[server-edit]."))))) 195 "When done with a buffer, type \\[server-edit].")))))
196 196
197 (defun server-visit-files (files client) 197 (defun server-visit-files (files client)
198 "Finds FILES and returns the list CLIENT with the buffers nconc'd. 198 "Finds FILES and returns the list CLIENT with the buffers nconc'd.
199 FILES is an alist whose elements are (FILENAME LINENUMBER)." 199 FILES is an alist whose elements are (FILENAME LINENUMBER)."
200 (let (client-record (obuf (current-buffer))) 200 ;; Bind last-nonmenu-event to force use of keyboard, not mouse, for queries.
201 (let (client-record (last-nonmenu-event t) (obuf (current-buffer)))
201 ;; Restore the current buffer afterward, but not using save-excursion, 202 ;; Restore the current buffer afterward, but not using save-excursion,
202 ;; because we don't want to save point in this buffer 203 ;; because we don't want to save point in this buffer
203 ;; if it happens to be one of those specified by the server. 204 ;; if it happens to be one of those specified by the server.
204 (unwind-protect 205 (unwind-protect
205 (while files 206 (while files
297 298
298 (add-hook 'kill-buffer-query-functions 299 (add-hook 'kill-buffer-query-functions
299 'server-kill-buffer-query-function) 300 'server-kill-buffer-query-function)
300 301
301 (defun server-kill-emacs-query-function () 302 (defun server-kill-emacs-query-function ()
302 (or (not server-clients) 303 (let (live-client
303 (yes-or-no-p "Server buffers still have clients; exit anyway? "))) 304 (tail server-clients))
305 ;; See if any clients have any buffers that are still alive.
306 (while tail
307 (if (memq t (mapcar 'stringp (mapcar 'buffer-name (cdr (car tail)))))
308 (setq live-client t))
309 (setq tail (cdr tail)))
310 (or (not live-client)
311 (yes-or-no-p "Server buffers still have clients; exit anyway? "))))
304 312
305 (add-hook 'kill-emacs-query-functions 'server-kill-emacs-query-function) 313 (add-hook 'kill-emacs-query-functions 'server-kill-emacs-query-function)
306 314
307 (defun server-edit (&optional arg) 315 (defun server-edit (&optional arg)
308 "Switch to next server editing buffer; say \"Done\" for current buffer. 316 "Switch to next server editing buffer; say \"Done\" for current buffer.