- (let* ((buffer (window-normalize-buffer buffer-or-name))
- (list (display-buffer-normalize-alist (buffer-name buffer) label))
- (value (assq 'other-window-means-other-frame
- (or (car list) (cdr list)))))
- (when value (cdr value))))
-
-(defun display-buffer-normalize-arguments (buffer-name specifiers label other-frame)
- "Normalize second and third argument of `display-buffer'.
-BUFFER-NAME is the name of the buffer that shall be displayed,
-SPECIFIERS is the second argument of `display-buffer'. LABEL is
-the same argument of `display-buffer'. OTHER-FRAME non-nil means
-use other-frame for other-window."
- (let (normalized entry specifier pars)
- (setq specifier
- (cond
- ((not specifiers)
- nil)
- ((listp specifiers)
- ;; If SPECIFIERS is a list, we assume it is a list of specifiers.
- (dolist (specifier specifiers)
- (cond
- ((consp specifier)
- (setq normalized (cons specifier normalized)))
- ((eq specifier 'other-window)
- ;; `other-window' must be treated separately.
- (let ((entry (assq (if other-frame
- 'other-frame
- 'same-frame-other-window)
- display-buffer-macro-specifiers)))
- (dolist (item (cdr entry))
- (setq normalized (cons item normalized)))))
- ((symbolp specifier)
- ;; Might be a macro specifier, try to expand it (the cdr is a
- ;; list and we have to reverse it later, so do it one at a
- ;; time).
- (let ((entry (assq specifier display-buffer-macro-specifiers)))
- (dolist (item (cdr entry))
- (setq normalized (cons item normalized)))))))
- ;; Reverse list.
- (nreverse normalized))
- ((setq entry (assq specifiers display-buffer-macro-specifiers))
- ;; A macro specifier.
- (cdr entry))
- ((or other-frame (with-no-warnings pop-up-frames))
- ;; `special-display-p' group.
- (if (and (with-no-warnings special-display-function)
- ;; `special-display-p' returns either t or a list
- ;; of frame parameters to pass to
- ;; `special-display-function'.
- (setq pars (with-no-warnings
- (special-display-p buffer-name))))
- (list (list 'function
- (with-no-warnings special-display-function)
- (when (listp pars) pars)))
- ;; Pop up another frame.
- (cddr (assq 'other-frame display-buffer-macro-specifiers))))
- (t
- ;; In any other case pop up a new window.
- (cdr (assq 'same-frame-other-window
- display-buffer-macro-specifiers)))))
-
- ;; Handle the old meaning of the LABEL argument of `display-buffer'.
- (cond
- ((or (memq label '(visible 0 t)) (frame-live-p label))
- ;; LABEL must be one of visible (and visible frame), 0 (any
- ;; visible or iconfied frame), t (any frame), or a live frame.
- (cons `(reuse-window nil same ,label) specifier))
- ((or other-frame
- (with-no-warnings pop-up-frames)
- (with-no-warnings display-buffer-reuse-frames))
- (cons '(reuse-window nil same 0) specifier))
- (t
- specifier))))
-
-(defun display-buffer-normalize-options (buffer-or-name)
+ (let* ((buffer-name
+ (buffer-name (window-normalize-buffer buffer-or-name)))
+ (default (display-buffer-normalize-default buffer-name))
+ (alist (display-buffer-normalize-alist buffer-name label)))
+ (or (cdr (assq 'other-window-means-other-frame default))
+ (cdr (assq 'other-window-means-other-frame (cdr alist))))))
+
+(defun display-buffer-normalize-special (&optional args)
+ "Return buffer display specifiers for `special-display-frame-alist'."
+ (progn ;; <-- reserved for with-no-warnings
+ (if (and (listp args) (symbolp (car args)))
+ ;; Note: `display-buffer' funcalls this so take "(nth 1 args)"
+ ;; where `special-display-popup-frame' (which uses apply) takes
+ ;; "(cdr args)".
+ `((function ,(car args) ,(nth 1 args)))
+ (append
+ '((reuse-window nil same 0))
+ (when (and (listp args) (cdr (assq 'same-window args)))
+ '((reuse-window same nil nil) (reuse-dedicated . weak)))
+ (when (and (listp args)
+ (or (cdr (assq 'same-frame args))
+ (cdr (assq 'same-window args))))
+ '((pop-up-window (largest . nil) (lru . nil))
+ (reuse-window nil nil nil)))
+ (unless display-buffer-mark-dedicated
+ ;; Don't make anything created above dedicated unless requested.
+ ;; Otherwise the dedication request below gets in our way.
+ '((dedicate . nil)))
+ `((pop-up-frame t)
+ ,(append '(pop-up-frame-alist)
+ (when (listp args) args)
+ special-display-frame-alist)
+ (dedicate . t))))))
+
+(defun display-buffer-normalize-default (buffer-or-name)