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

From: Peter Ludemann <[email-masked]>
Date: Wed, 1 Jun 2022 10:54:02 -0700

As Eli requested, restating what I'm asking ...

I start the emacs daemon from a terminal by:
    emacs --daemon

During startup, there might be some prompts (e.g., I get a
pagination prompt from parsing a tar file, when emacs is loading my last
session's files), and I can deal with them at the terminal.

When I shutdown the emacs daemon, I would like to also do this at the
terminal:
    emacsclient -e '(save-buffers-kill-emacs)'
but that doesn't work if there are any prompts (e.g., saving a file or
killing a shell process).
A work-around is to do:
    emacsclient -c -e '(save-buffers-kill-emacs)'
and that lets me see the prompts in the minibuffer.

However, it seems that "emacsclient -e" has access to the terminal's stderr.
Evidence: I get an error message at the terminal (not in a minibuffer) if I
do something with an error, such as
    emacsclient -e '(man fprintf)'

If stderr is being passed in to the evaluation code in daemon mode, then it
would be nice to also have stdin passed in, which would allow interaction
at the terminal.

However, this is a fairly minor improvement, given that "emacsclient -c -e"
works as expected, so probably it's not worth spending time on. (And the
documentation/emacswiki could be improved so that other people like me
don't bother you.)

On Tue, 31 May 2022 at 19:30, Eli Zaretskii <[email-masked]> wrote:

> > From: Peter Ludemann <[email-masked]>
> > Date: Tue, 31 May 2022 12:34:23 -0700
> > Cc: Michael Albinus <[email-masked]>, [email-masked]
> >
> > There's probably a solution to this, but it could be a lot of work for a
> small benefit.
>
> Could you please describe the problem for which you are looking for a
> solution?  During this discussion, you presented several issues that
> bothered you, so I'm no longer sure which of those we are now talking
> about.
>
> > However, I noticed that stderr appears to be available, when there's an
> error:
> >
> > $ emacsclient --eval '(man fprintf)'
> > *ERROR*: Symbol’s value as variable is void: fprintf
> >
> > and also when it works properly:
> >
> > $ emacsclient --eval "(list-buffers)"
> > #<window 194 on *Buffer List*>
>
> That's emacsclient's stderr, not that of the daemon.  And it can only
> print messages, not receive input.
>