From 18d7562e91d137b4e1efbd6c416f225af6efad3f Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Fri, 6 Aug 2021 02:36:22 +0300 Subject: [PATCH] Add function minibuffer-restore-windows (bug#45072) * lisp/minibuffer.el (minibuffer-restore-windows): New function that removes the completions buffer. Add it to minibuffer-exit-hook. * src/minibuf.c (read-minibuffer-restore-windows): Mention minibuffer-restore-windows. --- etc/NEWS | 2 ++ lisp/minibuffer.el | 10 ++++++++++ src/minibuf.c | 7 +++++-- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 5276a0981e9..1dd50a39bac 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 3751ba80e0a..3258e1ec8da 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -2328,6 +2328,16 @@ variables.") (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 3ee0dca5e05..a054f0e20dc 100644 --- a/src/minibuf.c +++ b/src/minibuf.c @@ -2535,8 +2535,11 @@ instead. */); 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); -- 2.39.2