From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: martin rudalics Newsgroups: gmane.emacs.bugs Subject: bug#11939: 24.1; `save-buffers-kill-emacs' loses minibuffer focus when it calls `list-processes' Date: Mon, 16 Jul 2012 11:12:18 +0200 Message-ID: <5003DAF2.2060400@gmx.at> References: <500173A5.3040608@gmx.at> <1986D90E22154321A44B6E0110CA4F5A@us.oracle.com> <50019C2F.8060103@gmx.at> <6B9036DBFDEF4881AB39804520BF63B3@us.oracle.com> <5002BEC6.3040106@gmx.at> <893E59C2E4F94D6EB910560C9E8C42CD@us.oracle.com> <5002EAF4.5080107@gmx.at> <6F73D04E8EE144E780D602DFEBA48E7B@us.oracle.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1342430009 2175 80.91.229.3 (16 Jul 2012 09:13:29 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 16 Jul 2012 09:13:29 +0000 (UTC) Cc: 11939@debbugs.gnu.org To: Drew Adams Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Jul 16 11:13:28 2012 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SqhMu-0005Vw-2Y for geb-bug-gnu-emacs@m.gmane.org; Mon, 16 Jul 2012 11:13:28 +0200 Original-Received: from localhost ([::1]:40778 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SqhMt-0008LV-BV for geb-bug-gnu-emacs@m.gmane.org; Mon, 16 Jul 2012 05:13:27 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:43448) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SqhMm-0008L3-Dv for bug-gnu-emacs@gnu.org; Mon, 16 Jul 2012 05:13:24 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SqhMa-0005Rh-T2 for bug-gnu-emacs@gnu.org; Mon, 16 Jul 2012 05:13:20 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:34160) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SqhMa-0005RR-OS for bug-gnu-emacs@gnu.org; Mon, 16 Jul 2012 05:13:08 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1SqhSI-0005fb-3P for bug-gnu-emacs@gnu.org; Mon, 16 Jul 2012 05:19:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: martin rudalics Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 16 Jul 2012 09:19:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 11939 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 11939-submit@debbugs.gnu.org id=B11939.134243028221715 (code B ref 11939); Mon, 16 Jul 2012 09:19:02 +0000 Original-Received: (at 11939) by debbugs.gnu.org; 16 Jul 2012 09:18:02 +0000 Original-Received: from localhost ([127.0.0.1]:43706 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SqhRJ-0005e7-5t for submit@debbugs.gnu.org; Mon, 16 Jul 2012 05:18:01 -0400 Original-Received: from mailout-de.gmx.net ([213.165.64.22]:52767) by debbugs.gnu.org with smtp (Exim 4.72) (envelope-from ) id 1SqhRG-0005dz-B9 for 11939@debbugs.gnu.org; Mon, 16 Jul 2012 05:17:59 -0400 Original-Received: (qmail invoked by alias); 16 Jul 2012 09:12:03 -0000 Original-Received: from 62-47-49-174.adsl.highway.telekom.at (EHLO [62.47.49.174]) [62.47.49.174] by mail.gmx.net (mp036) with SMTP; 16 Jul 2012 11:12:03 +0200 X-Authenticated: #14592706 X-Provags-ID: V01U2FsdGVkX19TD3NOXp5Tb8B+1Omhiv9oDb3D7EmcRP1Sldtkyw sb5bdkRQBGKdZa In-Reply-To: <6F73D04E8EE144E780D602DFEBA48E7B@us.oracle.com> X-Y-GMX-Trusted: 0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:61979 Archived-At: > I'm afraid I still do not understand (but maybe I don't need to). I thought the > problem has to do with input focus for minibuffer reading. But maybe you are > saying that the minibuffer need not be involved, and that `read-event' will also > depend on which frame has the focus. > > In any case, please give me the specific recipe that you would like me to try. > I'm afraid I've lost track at this point. `y-or-n-p' has the following two lines (when minibuffer-auto-raise (raise-frame (window-frame (minibuffer-window)))) So when you want to give focus to the minibuffer window you might want to replace `raise-frame' by the stronger `select-frame-set-input-focus' (when minibuffer-auto-raise (select-frame-set-input-focus (window-frame (minibuffer-window)))) For this to work you have to defalias `yes-or-no-p' to `y-or-n-p'. > And is this still pertinent, given what we have discovered wrt a reproducible > recipe from emacs -Q? As long as we have not found a solution, yes. >> I suppose that as long as you don't type either yes or no in the >> original frame nothing happens at all. > > Presumably _some_ buffer receives the input. If it is a read-only buffer then I > would expect a read-only error message. If it is not then I would expect to see > what I type in some buffer. I see neither effect. And presumably (it seems > that way anyway) it is the *Process List* buffer, which is read-only, that has > the focus. > > This behavior does not seem normal. You would have to try with `y-or-n-p'. read_minibuf has only Fmake_frame_visible (mini_frame); if (minibuffer_auto_raise) Fraise_frame (mini_frame); which might not be sufficient for your case. Once `y-or-n-p' with focus selection works we can try to make it work in read_minibuf too. > The frame for posing and answering all questions should be, as usual, the > minibuffer frame. Aside from `read-event' etc., reading user input should use > the minibuffer, and that means it should use the minibuffer frame. > > Looking at the C code for `yes-or-no-p' (Emacs 23.3), it clearly calls > `read-from-minibuffer' (`Fread_from_minibuffer'), so it should use the > minibuffer. The frame that should have the input focus for that prompt and > reading should be the standalone minibuffer frame - that is the _only_ frame > that has a minibuffer. > > It makes no sense for any other frame to have the input focus when reading from > the minibuffer, since no other frame _has_ a minibuffer. Most users don't care about standalone minibuffer frames. They want to see one frame where they find all information. >> > More precisely, I don't have much of an opinion in the >> > case of a non standalone minibuffer. >> > >> > But in the case of a standalone minibuffer, it definitely >> > should continue to have the input focus. That's the point, for me. >> >> Why "continue"? You could invoke C-x C-c in any frame. > > See above. It should have the input focus for any _reading from the > minibuffer_. Obviously, other frames can have the input focus when not reading > from the minibuffer. `yes-or-no-p' reads from the minibuffer. So if another frame has input focus and emacs asks a `yes-or-no-p' question, focus _should_ switch. > But the behavior I saw with that test indicated/suggested that *Help* was not > entirely special-display (with `pop-up-frames' t and the *Help* frame defined as > indicated with `special-display-buffer-names'. > > The frame was created with the correct colors etc., but buffer *Help* ended up > being replaced in the frame, which is not what "special display" means. So I > think there might be a second bug here. If this is independent from the behavior we discuss currently, we'll have to investigate it. >> > If I use Dired+ (which does what my patch does) then there >> > is no problem, so in my daily use this is solved for the >> > Dired but reported, but not in general (viz. >> > this bug wrt quitting with active processes). >> >> But your patch doesn't address the input focus issue or am I missing >> something? > > Correct. But the problem does not exist with my patch. I don't have an > explanation. Me neither. You would have to go through it and find what it does differently. > But please see the #15566 thread - in particular, the part about the use of code > that is nearly identical but that does not manifest the input problem. See the > message I sent that has the attachment `throw-chmod-vs-chmod-rec.el'. I do not > understand why what I report happens, but it happens. >> I have attached another version of `with-temp-buffer-window' which now >> explicitly shifts input focus to the frame selected at the time the >> macro is called. I hope this will fix the `pop-up-frames' t scenario. >> I'm afraid it will not fix the problem when you invoke C-x C-c in any >> window but the minibuffer-only window so we probably have to fix that >> issue separately. Please try it. > > Just what is the recipe to try (e.g. from emacs -Q)? With your usual setting load the file and test the shell and the dired scenarios. > Wrt "C-x C-c in any window but the minibuffer-only window": It's about reading > from the minibuffer (e.g. `read-from-minibuffer'). It never matters (apart from > this bug about new frames that get created during the minibuffer reading) which > buffer/frame is selected when you call `read-from-minibuffer'. Focus is always > switched to the minibuffer (and its frame). Because it does a simple `raise-frame' of the minibuffer frame which seems to work when you don't pop up another frame before. > The problem here seems to be that just after focus is correctly switched to the > minibuffer frame, for minibuffer interaction (reading), the new frame is popped > up and MS Windows gives it the focus. At least that's the (limited) conceptual > model I'm adopting so far. > > IOW, I don't think the problem is to give the minibuffer frame the focus. I'm > assuming that that is happening correctly, as usual. The problem, I think, is > that the new frame creation happens at the same time or just afterward, and that > steals the focus from the minibuffer frame (thanks to MS Windows). It doesn't help to speculate. I know of three functions to experiment with (`select-frame' and `raise-frame' being apparently too weak): - `select-frame-set-input-focus' which is probably too strong because it can change the Z-order thus obfuscating the frame where important information (like the list of directories to delete) is displayed, - `x-focus-frame' which should redirect any input to the frame argument, and - `redirect-frame-focus' which could be used to redirect input only from the frame where, for example, the marked directories are displayed to the minibuffer-only frame. You can try to experiment with these, either in `y-or-n-p' or in `with-temp-buffer-window'. If neither of these helps to direct focus away from the new frame, I see no solution. martin