From mboxrd@z Thu Jan  1 00:00:00 1970
Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail
From: Stefan Monnier via "Bug reports for GNU Emacs,
 the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
Newsgroups: gmane.emacs.bugs
Subject: bug#67249: 30.0.50; `same-frame` equivalent for `display-buffer-alist`
Date: Mon, 20 Nov 2023 08:33:46 -0500
Message-ID: <jwvwmucd0mq.fsf-monnier+emacs@gnu.org>
References: <jwv34x4m50o.fsf@iro.umontreal.ca>
 <159cd3c2-a0c4-63e2-ebb2-ce0f5f8c343e@gmx.at>
 <jwv1qcmfm22.fsf-monnier+emacs@gnu.org>
 <cbc6a073-2718-7809-c85e-cf338341c712@gmx.at>
 <jwvv89xesho.fsf-monnier+emacs@gnu.org>
 <69e6899b-9e93-9a97-a8bc-4ce9a9f0ae4c@gmx.at>
Reply-To: Stefan Monnier <monnier@iro.umontreal.ca>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214";
	logging-data="11920"; mail-complaints-to="usenet@ciao.gmane.io"
User-Agent: Gnus/5.13 (Gnus v5.13)
Cc: 67249@debbugs.gnu.org
To: martin rudalics <rudalics@gmx.at>
Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Nov 20 14:35:18 2023
Return-path: <bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org>
Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org
Original-Received: from lists.gnu.org ([209.51.188.17])
	by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
	(Exim 4.92)
	(envelope-from <bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org>)
	id 1r54Qo-0002uS-0g
	for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 20 Nov 2023 14:35:18 +0100
Original-Received: from localhost ([::1] helo=lists1p.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.90_1)
	(envelope-from <bug-gnu-emacs-bounces@gnu.org>)
	id 1r54QY-0003sD-NK; Mon, 20 Nov 2023 08:35:02 -0500
Original-Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <Debian-debbugs@debbugs.gnu.org>)
 id 1r54QW-0003rv-EH
 for bug-gnu-emacs@gnu.org; Mon, 20 Nov 2023 08:35:01 -0500
Original-Received: from debbugs.gnu.org ([2001:470:142:5::43])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <Debian-debbugs@debbugs.gnu.org>)
 id 1r54QW-0002nO-3y
 for bug-gnu-emacs@gnu.org; Mon, 20 Nov 2023 08:35:00 -0500
Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2)
 (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1r54QX-0001jr-Ri
 for bug-gnu-emacs@gnu.org; Mon, 20 Nov 2023 08:35:01 -0500
X-Loop: help-debbugs@gnu.org
Resent-From: Stefan Monnier <monnier@iro.umontreal.ca>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces@debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@gnu.org
Resent-Date: Mon, 20 Nov 2023 13:35:01 +0000
Resent-Message-ID: <handler.67249.B67249.17004872416597@debbugs.gnu.org>
Resent-Sender: help-debbugs@gnu.org
X-GNU-PR-Message: followup 67249
X-GNU-PR-Package: emacs
Original-Received: via spool by 67249-submit@debbugs.gnu.org id=B67249.17004872416597
 (code B ref 67249); Mon, 20 Nov 2023 13:35:01 +0000
Original-Received: (at 67249) by debbugs.gnu.org; 20 Nov 2023 13:34:01 +0000
Original-Received: from localhost ([127.0.0.1]:52806 helo=debbugs.gnu.org)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <debbugs-submit-bounces@debbugs.gnu.org>)
 id 1r54PZ-0001iD-26
 for submit@debbugs.gnu.org; Mon, 20 Nov 2023 08:34:01 -0500
Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:25930)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <monnier@iro.umontreal.ca>) id 1r54PU-0001ht-Gy
 for 67249@debbugs.gnu.org; Mon, 20 Nov 2023 08:33:59 -0500
Original-Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1])
 by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 80CA6441331;
 Mon, 20 Nov 2023 08:33:48 -0500 (EST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca;
 s=mail; t=1700487227;
 bh=KO93ErBOJiXsiuhgZDZxPcn/TNCP0LIZTDA28uDK5jw=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date:From;
 b=FJCWd+0u+cAlm8VBYTEUZPcd7B9U7TK2A7QlqZ8Yi2lIqnZEaALXglhNLPQv+b2oH
 jSBTzAiVuFePBeuBNy7rVqvz4RqvRtUnku6D+vCfNEvkn+95/dYVZF71Q4YUl+NREb
 qedGQenIEI6hg1INN5oXfwvD9olGwde3pLO5NGh6rmmdHqGiYyUe7l1bYSHCwE9Cwd
 Pjt+EhQxYErZrJbr4Q5Nb1s8I/fqBashbmj5qAm5FAvMUS3PaPZISOlMqgxq/rxsZa
 XvFySiYnPsQFdH2qv0gOHveOr71/aC1PggWTK2ZcS4AciRLVpB7GjTbh+3/A0C0xKn
 /F6vGXxDyoPxw==
Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1])
 by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 2FA624412B1;
 Mon, 20 Nov 2023 08:33:47 -0500 (EST)
Original-Received: from pastel (unknown [45.72.227.120])
 by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 0AE851202E0;
 Mon, 20 Nov 2023 08:33:47 -0500 (EST)
In-Reply-To: <69e6899b-9e93-9a97-a8bc-4ce9a9f0ae4c@gmx.at> (martin rudalics's
 message of "Mon, 20 Nov 2023 10:15:55 +0100")
X-BeenThere: debbugs-submit@debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
X-BeenThere: bug-gnu-emacs@gnu.org
List-Id: "Bug reports for GNU Emacs,
 the Swiss army knife of text editors" <bug-gnu-emacs.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/bug-gnu-emacs>,
 <mailto:bug-gnu-emacs-request@gnu.org?subject=unsubscribe>
List-Archive: <https://lists.gnu.org/archive/html/bug-gnu-emacs>
List-Post: <mailto:bug-gnu-emacs@gnu.org>
List-Help: <mailto:bug-gnu-emacs-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/bug-gnu-emacs>,
 <mailto:bug-gnu-emacs-request@gnu.org?subject=subscribe>
Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org
Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org
Xref: news.gmane.io gmane.emacs.bugs:274665
Archived-At: <http://permalink.gmane.org/gmane.emacs.bugs/274665>

> BTW creating a new frame is always one last resort of 'display-buffer'.

That depends on the rest of the config, AFAIK.
I tried the patch I sent on some of my config and it did have an effect
(e.g. when I open `M-x calendar`, depending the `same-frame` I either
get one frame with *Calendar* and another with `diary` or I get
a single frame with both.  Both windows are dedicated).

>> I don't see a big problem here: we could choose `same-frame` to imply
>> that `reusable-frames` is nil, or we could choose to ignore
>> `same-frame`.  Since the code that adds `(same-frame . t)` could just as well
>> also add `(reusable-frames)`, the first choice is less flexible
>> than the second (tho it allows overriding a higher-precedence
>> `reusable-frames` setting), so I'd go with the first choice, which also
>> has the advantage of not requiring any code modification :-)
>
> So a (same-frame . t) entry would simply auto-translate to a pair of
> (reusable-frames . nil) (lru-frames . nil) entries?

[ Hmm... I'm curious how you interpreted what I wrote to reach
  that conclusion.  ]
No, I meant the opposite: the users who want to override
`reusable-frames` and `lru-frames` need to add all three

    (same-frame . t)
    (reusable-frames . nil)
    (lru-frames . nil)

>> Another approach is to provide a new action.
>> This could be a `display-buffer-same-frame` action which tries its best
>> to use the selected frame.
>> I suspect in many cases the actual intention of `same-frame` was to keep
>> the buffer nearby, so I suspect we could also replace `same-frame` with
>> a `display-buffer-nearby` action.
>>
>> The advantage of an action is that we don't need to decide how existing
>> actions interact with it.
>
> We could add a 'display-buffer--same-frame-action' variable.

I don't really know what that suggestion means.
The `--` suggests it'd be some internal detail of `window.el` whereas
I thought we're discussing the externally visible API and semantics.

>>> Again applications that want to pop up a new frame would then have to
>>> provide a (same-frame . nil) entry.
>> That would seem fair game, IMO.
> It means a change in existing code.  Till now, applications were on the
> safe side in this regard since they could always blame others for using
> an obsolete feature.

I don't see why you think it'd require any change in existing code: the
ones who set `same-frame` get what they ask for.

>> I suspect the main exception would be minibuffer-only frames, but we
>> could get fancier if we feel like it (like when the selected frame can't
>> accommodate the `window-min-width` and `window-min-height`, or when we
>> set `inhibit-same-window` (or the selected window is dedicated) and the
>> frame's sole window can't be split).
>
> Do you anywhere see 'display-buffer' choose a minibuffer-only frame?

I'm not talking about `display-buffer` choosing a minibuffer-only frame.
I'm saying that when the selected-frame is a minibuffer-only frame, it's OK
to ignore the `same-frame` request.


        Stefan