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: Sat, 09 Dec 2023 17:29:06 -0500
Message-ID: <jwv1qbvm2o1.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>
 <jwvwmucd0mq.fsf-monnier+emacs@gnu.org>
 <69387717-1eaa-6019-0000-4c95c61e1bc3@gmx.at>
 <jwvwmubrkx7.fsf-monnier+emacs@gnu.org>
 <1f026837-af56-435f-9d4e-048a18af07eb@gmx.at>
 <jwv8r6pssbu.fsf-monnier+emacs@gnu.org>
 <a3b664a2-bb53-2f84-edb1-ab4d9d3567bd@gmx.at>
 <jwvlean7ulh.fsf-monnier+emacs@gnu.org>
 <488b181f-c74e-d97b-b168-a602158c3e7b@gmx.at>
 <jwv8r6n6z8t.fsf-monnier+emacs@gnu.org>
 <jwv8r6njf5k.fsf-monnier+emacs@gnu.org>
 <47d97021-75ea-cfc7-d439-cc38bc1044f4@gmx.at>
 <jwvwmu529iy.fsf-monnier+emacs@gnu.org>
 <jwvjzpvglal.fsf-monnier+emacs@gnu.org>
 <52b5fec2-510f-2fcd-c67c-2da18c91ab22@gmx.at>
Reply-To: Stefan Monnier <monnier@iro.umontreal.ca>
Mime-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214";
	logging-data="16799"; 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 Sat Dec 09 23:30:20 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 1rC5py-0004CH-TM
	for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 09 Dec 2023 23:30:19 +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 1rC5pX-0001Tr-Ew; Sat, 09 Dec 2023 17:29:51 -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 1rC5pV-0001TN-6J
 for bug-gnu-emacs@gnu.org; Sat, 09 Dec 2023 17:29:49 -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 1rC5pU-0003hF-UG
 for bug-gnu-emacs@gnu.org; Sat, 09 Dec 2023 17:29:48 -0500
Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2)
 (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1rC5pi-0000W6-C6
 for bug-gnu-emacs@gnu.org; Sat, 09 Dec 2023 17:30:02 -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: Sat, 09 Dec 2023 22:30:02 +0000
Resent-Message-ID: <handler.67249.B67249.17021609711930@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.17021609711930
 (code B ref 67249); Sat, 09 Dec 2023 22:30:02 +0000
Original-Received: (at 67249) by debbugs.gnu.org; 9 Dec 2023 22:29:31 +0000
Original-Received: from localhost ([127.0.0.1]:49144 helo=debbugs.gnu.org)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <debbugs-submit-bounces@debbugs.gnu.org>)
 id 1rC5pC-0000V3-OB
 for submit@debbugs.gnu.org; Sat, 09 Dec 2023 17:29:31 -0500
Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:21475)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <monnier@iro.umontreal.ca>) id 1rC5pA-0000Uo-0w
 for 67249@debbugs.gnu.org; Sat, 09 Dec 2023 17:29:29 -0500
Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1])
 by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 648D410019F;
 Sat,  9 Dec 2023 17:29:08 -0500 (EST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca;
 s=mail; t=1702160947;
 bh=CoXGhEIlUpbLeKygf/EYC8AWtBVvhZCAgXpfON3dxkU=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date:From;
 b=HoC5U+z2i8masiSkTTxPyaZBWc8Fz0s/p+pWZ/Uu7pHxjK/RBd8Vmig6VeMRb/IfV
 o7vL+wuMdio8YM5OJ7ECEVbyddnkEb9LPHz2PXk8GZZmhxAOeZang5R9fyqYPpP2AE
 nTD4klekl1FLDdjJAMrniL6OScJ901eIdh6UcRTUIqC7RM3Dx2JgliSXX//bvGu++U
 X+/gVtzFMnZgdTW6v+cLoNMbUp9MhDpReD3tUa3Ps3b+M4VUk9FcAhNyloElhGQIqV
 8Ku3INBHlu/gmZjJ27E2VTZvQuvSG4Qjy8QbH3mqNnCvpSTpfMWRkM7U1qxIhKQeYE
 y4eZkWxmMrmHA==
Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1])
 by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 5702E100189;
 Sat,  9 Dec 2023 17:29:07 -0500 (EST)
Original-Received: from pastel (unknown [45.72.207.126])
 by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 32B6A12020A;
 Sat,  9 Dec 2023 17:29:07 -0500 (EST)
In-Reply-To: <52b5fec2-510f-2fcd-c67c-2da18c91ab22@gmx.at> (martin rudalics's
 message of "Mon, 4 Dec 2023 08:23:01 +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:275884
Archived-At: <http://permalink.gmane.org/gmane.emacs.bugs/275884>

--=-=-=
Content-Type: text/plain

> Before pushing it, please try to fix the corresponding sections in the
> Elisp manual.  It will be non-trivial to avoid confusions with the old
> 'pop-up-frames' option.

How 'bout the patch below?


        Stefan

--=-=-=
Content-Type: text/x-diff
Content-Disposition: inline; filename=pop-up-frames.patch

diff --git a/doc/lispref/windows.texi b/doc/lispref/windows.texi
index 22c1b307252..7649013fce4 100644
--- a/doc/lispref/windows.texi
+++ b/doc/lispref/windows.texi
@@ -3433,9 +3433,13 @@ Choosing Window Options
 @end defopt
 
 @defopt pop-up-frames
-If the value of this variable is non-@code{nil}, that means
-@code{display-buffer} may display buffers by making new frames.  The
-default is @code{nil}.
+If the value of this parameter is non-@code{nil}, that means
+@code{display-buffer} may display buffers by making new frames.
+It can be specified in two ways: via the @code{pop-up-frames}
+variable and via a @code{pop-up-frames} entry in
+@code{display-buffer}'s @var{alist},
+where the entry in the alist takes precedence over the variable.
+The default is @code{nil}.
 
 A non-@code{nil} value also means that when @code{display-buffer} is
 looking for a window already displaying @var{buffer-or-name}, it can
diff --git a/etc/NEWS b/etc/NEWS
index 60391cfb22e..060d1a2fe5c 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1289,6 +1289,10 @@ values.
 
 * Lisp Changes in Emacs 30.1
 
+** New 'pop-up-frames' action alist entry for 'display-buffer'.
+This has the same effect as the variable of the same name and takes
+precedence over the variable when present.
+
 ** New function 'merge-ordered-lists'.
 Mostly used internally to do a kind of topological sort of
 inheritance hierarchies.
diff --git a/lisp/window.el b/lisp/window.el
index fbdcd611068..93c8ad7fad9 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -6862,6 +6862,7 @@ special-display-popup-frame
 If ARGS is a list whose car is a symbol, use (car ARGS) as a
 function to do the work.  Pass it BUFFER as first argument, and
 pass the elements of (cdr ARGS) as the remaining arguments."
+  (declare (obsolete display-buffer-pop-up-frame "30.1"))
   (if (and args (symbolp (car args)))
       (apply (car args) buffer (cdr args))
     (let ((window (get-buffer-window buffer 0)))
@@ -6881,9 +6882,8 @@ special-display-popup-frame
        ;; Stay on the same frame if requested.
        (when (or (cdr (assq 'same-frame args)) (cdr (assq 'same-window args)))
 	 (let* ((pop-up-windows t)
-		pop-up-frames
 		special-display-buffer-names special-display-regexps)
-	   (display-buffer buffer)))
+	   (display-buffer buffer '((pop-up-frames . nil)))))
        ;; If no window yet, make one in a new frame.
        (let* ((frame
 	       (with-current-buffer buffer
@@ -6996,6 +6996,13 @@ pop-up-frames
 	  (const :tag "Always" t))
   :group 'windows)
 
+(defun window--pop-up-frames (alist)
+ (let* ((override (assq 'pop-up-frames alist))
+        (pop-up (if override (cdr overriding) pop-up-frames)))
+   (if (eq pop-up 'graphic-only)
+       (display-graphic-p)
+     pop-up)))
+
 (defcustom display-buffer-reuse-frames nil
   "Non-nil means `display-buffer' should reuse frames.
 If the buffer in question is already displayed in a frame, raise
@@ -7742,6 +7749,8 @@ display-buffer
     Possible values are nil (the selected frame), t (any live
     frame), visible (any visible frame), 0 (any visible or
     iconified frame) or an existing live frame.
+ `pop-up-frames' -- Same effect as the eponymous variable.
+    Takes precedence over the variable.
  `pop-up-frame-parameters' -- The value specifies an alist of
     frame parameters to give a new frame, if one is created.
  `window-height' -- The value specifies the desired height of the
@@ -7830,12 +7839,12 @@ display-buffer
                           user-action special-action action extra-action
                           display-buffer-base-action
                           display-buffer-fallback-action))
-           (functions (apply 'append
+           (functions (apply #'append
                              (mapcar (lambda (x)
                                        (setq x (car x))
                                        (if (functionp x) (list x) x))
                                      actions)))
-           (alist (apply 'append (mapcar 'cdr actions)))
+           (alist (apply #'append (mapcar #'cdr actions)))
            window)
       (unless (buffer-live-p buffer)
         (error "Invalid buffer"))
@@ -7978,9 +7987,7 @@ display-buffer-reuse-window
 indirectly called by the latter."
   (let* ((alist-entry (assq 'reusable-frames alist))
 	 (frames (cond (alist-entry (cdr alist-entry))
-		       ((if (eq pop-up-frames 'graphic-only)
-			    (display-graphic-p)
-			  pop-up-frames)
+		       ((window--pop-up-frames alist)
 			0)
 		       (display-buffer-reuse-frames 0)
 		       (t (last-nonminibuffer-frame))))
@@ -8034,9 +8041,7 @@ display-buffer-reuse-mode-window
   (let* ((alist-entry (assq 'reusable-frames alist))
          (alist-mode-entry (assq 'mode alist))
 	 (frames (cond (alist-entry (cdr alist-entry))
-		       ((if (eq pop-up-frames 'graphic-only)
-			    (display-graphic-p)
-			  pop-up-frames)
+		       ((window--pop-up-frames alist)
 			0)
 		       (display-buffer-reuse-frames 0)
 		       (t (last-nonminibuffer-frame))))
@@ -8182,9 +8187,7 @@ display-buffer--maybe-pop-up-frame
 ALIST is an association list of action symbols and values.  See
 Info node `(elisp) Buffer Display Action Alists' for details of
 such alists."
-  (and (if (eq pop-up-frames 'graphic-only)
-	   (display-graphic-p)
-	 pop-up-frames)
+  (and (window--pop-up-frames alist)
        (display-buffer-pop-up-frame buffer alist)))
 
 (defun display-buffer--maybe-pop-up-window (buffer alist)
@@ -8548,9 +8551,7 @@ display-buffer-in-previous-window
 	  (cdr (assq 'inhibit-same-window alist)))
 	 (frames (cond
 		  (alist-entry (cdr alist-entry))
-		  ((if (eq pop-up-frames 'graphic-only)
-		       (display-graphic-p)
-		     pop-up-frames)
+		  ((window--pop-up-frames alist)
 		   0)
 		  (display-buffer-reuse-frames 0)
 		  (t (last-nonminibuffer-frame))))

--=-=-=--