all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@linkov.net>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: bugs@gnu.support, 45072@debbugs.gnu.org
Subject: bug#45072: 28.0.50; Emacs switches other buffer back uncontrollably, if other window's buffer is changed by user during minibuffer editing
Date: Wed, 04 Aug 2021 23:17:20 +0300	[thread overview]
Message-ID: <87r1f976rr.fsf@mail.linkov.net> (raw)
In-Reply-To: <87lf5hlh9m.fsf@gnus.org> (Lars Ingebrigtsen's message of "Wed, 04 Aug 2021 10:56:53 +0200")

>>>> +  ;; When read_minibuf doesn't restore all previous windows,
>>>> +  ;; then at least pop down the completions window.
>>>> +  (unless read-minibuffer-restore-windows
>>>> +    (minibuffer-hide-completions))
>>>
>>> Hm...  Well, I guess that's what most people would want...  but...
>>
>> The new option read-minibuffer-restore-windows is quite unusable
>> without the above change: selecting a completion from the
>> completions buffer will leave the completions buffer on the screen.
>
> Yes.  But I think some people would want that -- that is, they might be
> `C-g'-ing out of the minubuffer just because they want to copy some of
> the text in the completions buffer.
>
> But on the other hand, that may be such a rare thing to do that just
> applying your proposed patch is the right thing, and then we could just
> see whether anybody actually requests that before tinkering any further
> with it...
>
> So...  I think you should just push the patch, and then we'll see.

Actually, my previous patch doesn't handle the case of `C-g'-ing
out of the minubuffer.  It hides the completions buffer
only after exiting in the normal way by RET.

But fortunately there is an existing hook 'minibuffer-exit-hook'
called in both cases of exiting by `C-g' and RET.
And the users can easily change it, e.g. to not pop down
the *Completions* buffer, or to remove more windows, etc.

diff --git a/etc/NEWS b/etc/NEWS
index f0fa686bc9..cca6956275 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -180,6 +180,8 @@ nor t.
 
 +++
 ** New user option 'read-minibuffer-restore-windows'.
+When customized to nil, it uses 'minibuffer-restore-windows' in
+'minibuffer-exit-hook' to remove only the *Completions* window.
 
 +++
 ** New system for displaying documentation for groups of functions.
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index 3751ba80e0..79fb7e6afc 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -2328,6 +2342,16 @@ exit-minibuffer
   (setq deactivate-mark nil)
   (throw 'exit nil))
 
+(defun minibuffer-restore-windows ()
+  "Restore some windows on exit from minibuffer.
+When `read-minibuffer-restore-windows' is nil, then this function
+added to `minibuffer-exit-hook' will remove at least the window
+with the *Completions* buffer."
+  (unless read-minibuffer-restore-windows
+    (minibuffer-hide-completions)))
+
+(add-hook 'minibuffer-exit-hook 'minibuffer-restore-windows)
+
 (defun minibuffer-quit-recursive-edit ()
   "Quit the command that requested this recursive edit without error.
 Like `abort-recursive-edit' without aborting keyboard macro
diff --git a/src/minibuf.c b/src/minibuf.c
index 3ee0dca5e0..a054f0e20d 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -2535,8 +2535,11 @@ syms_of_minibuf (void)
 If this is non-nil (the default), reading input with the minibuffer will
 restore, on exit, the window configurations of the frame where the
 minibuffer was entered from and, if it is different, the frame that owns
-the associated minibuffer window.  If this is nil, no such restorations
-are done.  */);
+the associated minibuffer window.
+
+If this is nil, no such restorations are done.
+But still `minibuffer-restore-windows' in `minibuffer-exit-hook'
+will remove the window with the *Completions* buffer.  */);
   read_minibuffer_restore_windows = true;
 
   defsubr (&Sactive_minibuffer_window);





  reply	other threads:[~2021-08-04 20:17 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-06 14:07 bug#45072: 28.0.50; Emacs switches other buffer back uncontrollably, if other window's buffer is changed by user during minibuffer editing Jean Louis
2020-12-07 16:10 ` Lars Ingebrigtsen
2020-12-07 16:42   ` Jean Louis
2020-12-07 17:20     ` Eli Zaretskii
2020-12-07 18:49       ` Jean Louis
2020-12-07 19:27         ` Eli Zaretskii
2020-12-07 19:45           ` Jean Louis
2020-12-08  8:09           ` martin rudalics
2020-12-08 14:09             ` Lars Ingebrigtsen
2020-12-08 14:18               ` Jean Louis
2020-12-08 14:47               ` martin rudalics
2020-12-08 14:58                 ` Jean Louis
2020-12-08 16:08                   ` Eli Zaretskii
2020-12-08 16:14                     ` Jean Louis
2020-12-08 15:51               ` Eli Zaretskii
2020-12-09  9:33                 ` martin rudalics
2021-08-03  7:57                   ` Juri Linkov
2021-08-04  6:52                     ` Lars Ingebrigtsen
2021-08-04  8:39                       ` Juri Linkov
2021-08-04  8:56                         ` Lars Ingebrigtsen
2021-08-04 20:17                           ` Juri Linkov [this message]
2021-08-05 10:55                             ` Lars Ingebrigtsen
2021-08-05 23:36                               ` Juri Linkov
2020-12-08 19:15             ` Juri Linkov
2020-12-09  9:34               ` martin rudalics
2020-12-09 10:06                 ` Jean Louis
2020-12-09 15:16                   ` martin rudalics
2020-12-09 19:11                 ` Juri Linkov
2020-12-10  7:44                   ` martin rudalics
2020-12-10  8:30                     ` Jean Louis
2020-12-10  9:46                       ` martin rudalics
2020-12-10 10:16                         ` Jean Louis
2020-12-10 11:52                           ` martin rudalics
2020-12-10 12:07                             ` Jean Louis
2020-12-11  9:39                               ` Juri Linkov
2020-12-12  1:47                                 ` Jean Louis
2020-12-10  8:32                     ` Juri Linkov
2020-12-10  9:47                       ` martin rudalics
2020-12-10 10:21                         ` Jean Louis
2020-12-10 11:52                           ` martin rudalics
2020-12-10 12:21                             ` Jean Louis
2020-12-12 20:49                         ` Juri Linkov
2020-12-13  7:26                           ` martin rudalics
2020-12-14 20:28                             ` Juri Linkov
2020-12-15  7:59                               ` martin rudalics
2021-01-15  8:57                               ` Juri Linkov
2021-04-19 13:54                                 ` Stefan Monnier
2021-04-19 16:02                                   ` martin rudalics
2021-04-19 18:09                                     ` Juri Linkov
2021-04-19 13:52                               ` Stefan Monnier
2021-04-19 16:02                                 ` martin rudalics
2021-04-19 16:22                                   ` Stefan Monnier
2021-04-19 17:11                                     ` martin rudalics
2020-12-08  5:33       ` Richard Stallman
2020-12-08 15:13         ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87r1f976rr.fsf@mail.linkov.net \
    --to=juri@linkov.net \
    --cc=45072@debbugs.gnu.org \
    --cc=bugs@gnu.support \
    --cc=larsi@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.