GNU bug report logs - #22997
25.0.50; reusing windows in pop-to-buffer while in completion-in-region-mode opens new frames

Previous Next

Package: emacs;

Reported by: joaotavora <at> gmail.com (João Távora)

Date: Sat, 12 Mar 2016 16:34:01 UTC

Severity: normal

Found in version 25.0.50

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 22997 in the body.
You can then email your comments to 22997 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#22997; Package emacs. (Sat, 12 Mar 2016 16:34:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to joaotavora <at> gmail.com (João Távora):
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sat, 12 Mar 2016 16:34:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: joaotavora <at> gmail.com (João Távora)
To: bug-gnu-emacs <at> gnu.org
Subject: 25.0.50;
 reusing windows in pop-to-buffer while in completion-in-region-mode
 opens new frames
Date: Sat, 12 Mar 2016 16:32:50 +0000
Hi maintainers,

Emacs -Q and use just this customization

  (setq display-buffer-base-action
        `(display-buffer-reuse-window . ((inhibit-same-window . t))))

Do something that enters completion-in-region-mode. While in that
transient mode, invoke something that pops a buffer.

  d i s p l a  M-x complete-symbol RET
  M-x pop-to-buffer RET *Messages* RET

A new frame is created even though pop-up-frames is nil. I believe the
reason is that the *Completions* window is "soft-dedicated" in
minibuffer.el.

My fix would be to exit the transient completion-in-region-mode before
displaying other buffers. This can be done by setting
display-buffer-alist appropriately in completion-in-region-mode, much
like it sets and resets minor-mode-overriding-map-alist.

I've tried this in an extension of mine, SLY, with a mode very similar
to completion-in-region-mode, but the same technique doesn't work there
for some reason.

Anyway, the _failed_ patch after my signature.
João

diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index 2814d02..c115476 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -2024,6 +2024,9 @@ completion-in-region-mode
   (setq minor-mode-overriding-map-alist
         (delq (assq 'completion-in-region-mode minor-mode-overriding-map-alist)
               minor-mode-overriding-map-alist))
+  (setq display-buffer-alist
+        (delq (assq 'completion--in-region-mode-display-guard-p display-buffer-alist)
+              display-buffer-alist))
   (if (null completion-in-region-mode)
       (progn
         (setq completion-in-region--data nil)
@@ -2035,7 +2038,11 @@ completion-in-region-mode
 	  completion-in-region-mode-predicate)
     (add-hook 'post-command-hook #'completion-in-region--postch)
     (push `(completion-in-region-mode . ,completion-in-region-mode-map)
-          minor-mode-overriding-map-alist)))
+          minor-mode-overriding-map-alist)
+    (push `(completion--in-region-mode-display-guard-p
+            (completion--in-region-mode-teardown-before-displaying-others
+             . ,display-buffer-alist))
+          display-buffer-alist)))
 
 ;; Define-minor-mode added our keymap to minor-mode-map-alist, but we want it
 ;; on minor-mode-overriding-map-alist instead.
@@ -2043,6 +2050,17 @@ completion-in-region-mode
       (delq (assq 'completion-in-region-mode minor-mode-map-alist)
             minor-mode-map-alist))
 
+;; Do some crazy `display-buffer-alist' antics to prevent the
+;; soft-dedication of *Completions* to interfere with normal
+;; display-buffer
+(defun completion--in-region-mode-display-guard-p (buffer-name _alist)
+  (not (equal "*Completions*" buffer-name)))
+
+(defun completion--in-region-mode-teardown-before-displaying-others (_buffer _action)
+  (completion-in-region-mode -1)
+  ;; explicitly return nil, for clarity
+  nil)
+
 (defvar completion-at-point-functions '(tags-completion-at-point-function)
   "Special hook to find the completion table for the thing at point.
 Each function on this hook is called in turn without any argument and should




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#22997; Package emacs. (Wed, 02 Dec 2020 12:38:01 GMT) Full text and rfc822 format available.

Message #8 received at 22997 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: joaotavora <at> gmail.com (João Távora)
Cc: 22997 <at> debbugs.gnu.org
Subject: Re: bug#22997: 25.0.50; reusing windows in pop-to-buffer while in
 completion-in-region-mode opens new frames
Date: Wed, 02 Dec 2020 13:37:02 +0100
joaotavora <at> gmail.com (João Távora) writes:

> Emacs -Q and use just this customization
>
>   (setq display-buffer-base-action
>         `(display-buffer-reuse-window . ((inhibit-same-window . t))))
>
> Do something that enters completion-in-region-mode. While in that
> transient mode, invoke something that pops a buffer.
>
>   d i s p l a  M-x complete-symbol RET
>   M-x pop-to-buffer RET *Messages* RET
>
> A new frame is created even though pop-up-frames is nil. I believe the
> reason is that the *Completions* window is "soft-dedicated" in
> minibuffer.el.

I'm unable to reproduce this problem in Emacs 28, but I'm not sure I
understand the recipe -- surely Emacs doesn't pop up a new frame on
pop-to-buffer without further customisation?  So is there something
missing in the recipe, or has the bug just gone away over the years?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#22997; Package emacs. (Wed, 02 Dec 2020 12:45:02 GMT) Full text and rfc822 format available.

Message #11 received at 22997 <at> debbugs.gnu.org (full text, mbox):

From: João Távora <joaotavora <at> gmail.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 22997 <at> debbugs.gnu.org
Subject: Re: bug#22997: 25.0.50; reusing windows in pop-to-buffer while in
 completion-in-region-mode opens new frames
Date: Wed, 2 Dec 2020 12:44:26 +0000
 On Wed, Dec 2, 2020 at 12:37 PM Lars Ingebrigtsen <larsi <at> gnus.org> wrote:

Hi Lars,

> surely Emacs doesn't pop up a new frame on
> pop-to-buffer without further customisation?

When pop-to-buffer finds itself in a tight spot (no space on current frame),
I think it will/would in certain situations pop a new frame.

> So is there something
> missing in the recipe, or has the bug just gone away over the years?

I have a vague recollection that the recipe was accurate, and eventually
something in window.el was fixed, by me or Martin or both.  Likely I
forgot to x-ref the bug id.  If you can't reproduce it, I think you should
just close this bug.

Hey, I found commit 5d34e1b2881caa5743816030c2e9cdcda58e9719
that looks relevant.

João




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#22997; Package emacs. (Thu, 03 Dec 2020 08:43:02 GMT) Full text and rfc822 format available.

Message #14 received at 22997 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: João Távora <joaotavora <at> gmail.com>
Cc: 22997 <at> debbugs.gnu.org
Subject: Re: bug#22997: 25.0.50; reusing windows in pop-to-buffer while in
 completion-in-region-mode opens new frames
Date: Thu, 03 Dec 2020 09:42:33 +0100
João Távora <joaotavora <at> gmail.com> writes:

>> So is there something
>> missing in the recipe, or has the bug just gone away over the years?
>
> I have a vague recollection that the recipe was accurate, and eventually
> something in window.el was fixed, by me or Martin or both.  Likely I
> forgot to x-ref the bug id.  If you can't reproduce it, I think you should
> just close this bug.

OK, closing.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug closed, send any further explanations to 22997 <at> debbugs.gnu.org and joaotavora <at> gmail.com (João Távora) Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Thu, 03 Dec 2020 08:43:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 31 Dec 2020 12:24:10 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 171 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.