Subject: bug#31951: 27.0.50; [PATCH] server-save-buffers-kill-terminal should respect save-some-buffers-default-predicate

From: Noam Postavsky <[email-masked]>
Date: Sun, 24 Jun 2018 09:37:26 -0400

João Távora <[email-masked]> writes:

> If the Emacs client was started without an explicit list of buffers to
> edit, save-some-buffers is called with t for PRED (save all buffers),
> but that was before save-some-buffers-default-predicate existed.
>
> I don't see any reason why save-some-buffers-default-predicate shouldn't
> be respected in server-save-buffers-kill-terminal (of course if ARG is
> non-nil, we do pass t so that the previous behaviour remains).

>	     ;; If client is bufferless, emulate a normal Emacs exit
>	     ;; and offer to save all buffers.  Otherwise, offer to
>	     ;; save only the buffers belonging to the client.
>  	     (save-some-buffers
> -	      arg (if buffers
> -		      (lambda () (memq (current-buffer) buffers))
> -		    t))
> +	      arg (and buffers
> +		       (lambda () (memq (current-buffer) buffers))
> +                       (and arg t)))

I think you meant

+	      arg (if buffers
+		      (lambda () (memq (current-buffer) buffers))
+                   (and arg t))

But I'm not sure if this change makes sense, seeing as
save-buffers-kill-emacs also ignores
save-some-buffers-default-predicate:

    (defun save-buffers-kill-emacs (&optional arg)
      [...]
      ;; Don't use save-some-buffers-default-predicate, because we want
      ;; to ask about all the buffers before killing Emacs.
      (save-some-buffers arg t)