Function: server-save-buffers-kill-terminal

server-save-buffers-kill-terminal is an autoloaded and byte-compiled function defined in server.el.gz.

Signature

(server-save-buffers-kill-terminal ARG)

Documentation

Offer to save each buffer, then kill the current client.

With ARG non-nil, silently save all file-visiting buffers, then kill.

If emacsclient was started with a list of filenames to edit, then only these files will be asked to be saved.

Source Code

;; Defined in /usr/src/emacs/lisp/server.el.gz
;;;###autoload
(defun server-save-buffers-kill-terminal (arg)
  ;; Called from save-buffers-kill-terminal in files.el.
  "Offer to save each buffer, then kill the current client.
With ARG non-nil, silently save all file-visiting buffers, then kill.

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 nil 'client)))
    (cond ((eq proc 'nowait)
	   ;; Nowait frames have no client buffer list.
	   (if (cdr (frame-list))
	       (progn (save-some-buffers arg)
		      (delete-frame))
	     ;; If we're the last frame standing, kill Emacs.
	     (save-buffers-kill-emacs arg)))
	  ((processp proc)
	   (let ((buffers (process-get proc 'buffers)))
	     (save-some-buffers
	      arg (if buffers
                      ;; Only files from emacsclient file list.
		      (lambda () (memq (current-buffer) buffers))
                    ;; No emacsclient file list: don't override
                    ;; `save-some-buffers-default-predicate' (unless
                    ;; ARG is non-nil), since we're not killing
                    ;; Emacs (unlike `save-buffers-kill-emacs').
		    (and arg t)))
	     (server-delete-client proc)))
	  (t (error "Invalid client frame")))))