Subject: bug#55599: save-buffers-kill-emacs doesn't give a visible prompt when called from command line

From: Eli Zaretskii <[email-masked]>
Date: Tue, 24 May 2022 14:31:16 +0300

> Cc: [email-masked]
> From: Peter Ludemann <[email-masked]>
> Date: Tue, 24 May 2022 02:29:37 -0700
> 
> I don't want to unconditionally save buffers; I want to conditionally save them. (Actually, I wouldn't mind if it
> didn't save the buffers at all; when I restart emacs, it finds the ".#" files, and that suffices.)
> 
> There's a more general problem here (although you might decide it's too much trouble to fix) -- it seems that
> when "emacsclient -e" is used, any prompts go to the non-existent screen rather than to the terminal. (e.g.,
> yes-or-n-p's prompt).

"emacsclient -e" is not meant to support execution of interactive Lisp
programs, especially not when there's no client frame through which to
interact with the user.  If you want interaction via emacsclient,
start emacsclient normally, and then invoke those interactive Lisp
programs in the client frame that the server opens.

I see no bugs in the behavior you report, and no change from previous
Emacs versions.  So I'm unsure what issues are being discussed here
(but see below).

> Also, save-buffers-kill-emacs does two things: (conditionally) saves the buffers and deletes the
> ~/.emacs.d/.emacs.desktop.lock file. On the other hand, the lower level kill-emacs doesn't delete the lock file
> (and the response to bug 55560 is that that's a deliberate design decision). So, there's no way of doing from
> the command line "kill-emacs-and-remove-lock-file", it seems.

You can do anything from the command line, as long as you make sure
the Lisp program you invoke via the -e switch doesn't ask any
questions.  E.g., you can invoke a Lisp program that deletes the
desktop lock file in a kill-emacs-hook, provided that you write such a
hook yourself and set it in the same Lisp program you pass via -e.

The change that triggered this bug report supports "normal" use of
emacsclient, whereby the server session is terminated interactively.
If you insist on doing that noninteractively, you will have to write
your own Lisp program to do that.  Alternatively, feel free to request
a new feature of emacsclient whereby you could terminate the server
session non-interactively via some new command-line option; then the
implementation of such a feature will have to do all that internally.