Subject: Re: bug#34614: 26.1.92; When reading input in mini-buffer, message to each area overide the input prompt

From: Zhang Haijun <[email-masked]>
Date: Thu, 14 Nov 2019 00:44:35 +0000

> 在 2019年11月12日，下午4:10，martin rudalics <[email-masked]> 写道：
> 
> > Thanks. I think it will be better if emacs can record the last
> > buffer(Including minibuffer) selected manually by the user
> 
> That will be next to impossible.
> 
> > and provide
> > a function like selected-buffer to return this buffer.
> > And minibuffer-message can use this.
> >
> > old-selected-window does exactly the same - it records the last window,
> > and getting its buffer is easy with just window-buffer.
> >
> > Doesn’t set-buffer and with-current-buffer change the current buffer in the window?
> 
> No.  Only set_window_buffer does that.
> 
> > They are not selected manually by user.
> 
> How would you know?
> 
> martin
> 

Then is it possible to provide a function which returns whether the current context is in the foreground thread or in a background thread(a timer callback or a background thread)?

If the former, it can use the minibuffer freely.

If the latter, it can't. If it outputs messages, the minibuffer should be protected. If it reads user input, it should be queued and blocked.

I think it is not safe to call y-or-n-p in a timer callback, because user may be editing a file and typing 'y'. So the above checking should be done in low level function like y-or-n-p.