Package: emacs;
Reported by: Stefan Monnier <monnier <at> iro.umontreal.ca>
Date: Fri, 17 Nov 2023 21:43:02 UTC
Severity: normal
Found in version 30.0.50
Done: Stefan Monnier <monnier <at> iro.umontreal.ca>
Bug is archived. No further changes may be made.
View this message in rfc822 format
From: Stefan Monnier <monnier <at> iro.umontreal.ca> To: martin rudalics <rudalics <at> gmx.at> Cc: 67249 <at> debbugs.gnu.org Subject: bug#67249: 30.0.50; `same-frame` equivalent for `display-buffer-alist` Date: Sat, 09 Dec 2023 17:29:06 -0500
[Message part 1 (text/plain, inline)]
> 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
[pop-up-frames.patch (text/x-diff, inline)]
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))))
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.