]> code.delx.au - gnu-emacs/blobdiff - lisp/window.el
Update doc-string of display-buffer-alist.
[gnu-emacs] / lisp / window.el
index cad4e15507d2021f30c991ada2f63f213faebcf4..a4baf99d956ac5a04e3e5f1ed7683a402aaf9d2c 100644 (file)
@@ -2044,7 +2044,18 @@ make selected window wider by DELTA columns.  If DELTA is
 negative, shrink selected window by -DELTA lines or columns.
 Return nil."
   (interactive "p")
-  (resize-window (selected-window) delta horizontal))
+  (cond
+   ((zerop delta))
+   ((window-size-fixed-p nil horizontal)
+    (error "Selected window has fixed size"))
+   ((window-resizable-p nil delta horizontal)
+    (resize-window nil delta horizontal))
+   (t
+    (resize-window
+     nil (if (> delta 0)
+            (window-max-delta nil horizontal)
+          (- (window-min-delta nil horizontal)))
+     horizontal))))
 
 (defun shrink-window (delta &optional horizontal)
   "Make selected window DELTA lines smaller.
@@ -2054,7 +2065,18 @@ make selected window narrower by DELTA columns.  If DELTA is
 negative, enlarge selected window by -DELTA lines or columns.
 Return nil."
   (interactive "p")
-  (resize-window (selected-window) (- delta) horizontal))
+  (cond
+   ((zerop delta))
+   ((window-size-fixed-p nil horizontal)
+    (error "Selected window has fixed size"))
+   ((window-resizable-p nil (- delta) horizontal)
+    (resize-window nil (- delta) horizontal))
+   (t
+    (resize-window
+     nil (if (> delta 0)
+            (- (window-min-delta nil horizontal))
+          (window-max-delta nil horizontal))
+     horizontal))))
 
 (defun maximize-window (&optional window)
   "Maximize WINDOW.
@@ -3453,9 +3475,8 @@ specific buffers."
     ;; (bw-finetune wins)
     ;; (message "Done in %d rounds" round)
     ))
-
-\f
 \f
+;;; Displaying buffers.
 (defconst display-buffer-default-specifiers
   '((reuse-window nil same visible)
     (pop-up-window (largest . nil) (lru . nil))
@@ -3479,12 +3500,11 @@ buffer display specifiers.")
      (reuse-window nil same nil)
      (pop-up-window (largest . nil) (lru . nil))
      (reuse-window nil other nil))
-    (other-window
-     ;; Avoid selected window.
-     (reuse-window other same visible)
-     (pop-up-window (largest . nil) (lru . nil))
-     (pop-up-frame)
-     (reuse-window other other visible))
+    ;; (other-window
+    ;;  ;; Avoid selected window.
+    ;;  (reuse-window other same visible)
+    ;;  (pop-up-window (largest . nil) (lru . nil))
+    ;;  (reuse-window other other visible))
     (same-frame-other-window
      ;; Avoid other frames and selected window.
      (reuse-window other same nil)
@@ -3502,12 +3522,16 @@ buffer display specifiers.")
 
 (defcustom display-buffer-alist
   '((((regexp . ".*"))
+     ;; Reuse window showing same buffer.
      reuse-window (reuse-window nil same visible)
+     ;; Pop up window.
      pop-up-window
+     ;; Split largest or lru window.
      (pop-up-window (largest . nil) (lru . nil))
-     pop-up-frame
-     (pop-up-frame)
-     reuse-window (reuse-window nil other visible)
+     (pop-up-window-min-height . 40) ; split-height-threshold / 2
+     (pop-up-window-min-width . 80) ; split-width-threshold / 2
+     ;; Reuse any but selected window on same frame.
+     reuse-window (reuse-window other nil nil)
      (reuse-window-even-sizes . t)))
   "List associating buffer identifiers with display specifiers.
 The car of each element of this list is built from a set of cons
@@ -3768,6 +3792,14 @@ supported:
 
 - t to strongly dedicate the window to the buffer.
 
+A cons cell whose car is `other-window-means-other-frame' and
+whose cdr is non-nil means that you want calls of
+`display-buffer' with the second argument t or the symbol
+`other-window' to display the buffer in another frame.  This
+means, for example, that you prefer functions like
+`find-file-other-window' or `switch-to-buffer-other-window' to
+make a new frame instead of a new window on the selected frame.
+
 Usually, applications are free to override the specifiers of
 `display-buffer-alist' by passing their own specifiers as second
 argument of `display-buffer'.  For every `display-buffer-alist'
@@ -4212,6 +4244,15 @@ using the location specifiers `same-window' or `other-frame'."
        :format "%[No other window%] %v\n" :size 15
        (const :tag "Off" :format "%t" nil)
        (const :tag "Ignore" :format "%t" t)))
+      ;; Other window means other frame.
+      (cons
+       :format "%v"
+       (const :format "" other-window-means-other-frame)
+       (choice
+       :help-echo "Whether other window means same or other frame."
+       :format "%[Same or other frame%] %v\n" :size 15
+       (const :tag "Same frame" :format "%t" nil)
+       (const :tag "Other frame" :format "%t" t)))
       ;; Overriding.
       (cons
        :format "%v\n"
@@ -4707,7 +4748,8 @@ non-nil means to make a new frame on graphic displays only.
 
 SPECIFIERS must be a list of buffer display specifiers, see the
 documentation of `display-buffer-alist' for a description."
-  (unless (and graphic-only (not (display-graphic-p)))
+  (unless (or (and graphic-only (not (display-graphic-p)))
+             noninteractive)
     (let* ((selected-window (selected-window))
           (function (or (cdr (assq 'pop-up-frame-function specifiers))
                         'make-frame))
@@ -4895,6 +4937,26 @@ SPECIFIERS must be a list of buffer display specifiers."
          (set-window-parameter window 'window-slot slot))
        (display-buffer-in-window buffer window specifiers)))))
 
+(defun display-buffer-other-window-means-other-frame (buffer-or-name &optional label)
+  "Return non-nil if BUFFER shall be preferably displayed in another frame.
+BUFFER must be a live buffer or the name of a live buffer.
+
+Return nil if BUFFER shall be preferably displayed in another
+window on the selected frame.  Return non-nil if BUFFER shall be
+preferably displayed in a window on any but the selected frame.
+
+Optional argument LABEL is like the same argument of
+`display-buffer'.
+
+The calculation of the return value is exclusively based on the
+user preferences expressed in `display-buffer-alist'."
+  (let* ((buffer (normalize-live-buffer buffer-or-name))
+        (list (display-buffer-normalize-specifiers-3
+               (buffer-name buffer) label))
+        (value (assq 'other-window-means-other-frame
+                     (or (car list) (cdr list)))))
+    (when value (cdr value))))
+
 (defun normalize-buffer-to-display (buffer-or-name)
   "Normalize BUFFER-OR-NAME argument for buffer display functions.
 If BUFFER-OR-NAME is nil, return the curent buffer.  Else, if a
@@ -4908,16 +4970,29 @@ BUFFER-OR-NAME and return that buffer."
            buffer))
     (current-buffer)))
 
-(defun display-buffer-normalize-specifiers-1 (specifiers)
+(defun display-buffer-normalize-specifiers-1 (specifiers buffer-name label)
   "Subroutine of `display-buffer-normalize-specifiers'.
-SPECIFIERS is the SPECIFIERS argument of `display-buffer'."
-  (let (normalized)
+SPECIFIERS is a list of buffer display specfiers.  BUFFER-NAME is
+the name of the buffer that shall be displayed, LABEL the same
+argument of `display-buffer'."
+  (let (normalized entry)
     (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* ((other-frame (display-buffer-other-window-means-other-frame
+                              buffer-name label))
+                (entry (assq (if other-frame 'other-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
@@ -4926,21 +5001,16 @@ SPECIFIERS is the SPECIFIERS argument of `display-buffer'."
            (dolist (item (cdr entry))
              (setq normalized (cons item normalized)))))))
       ;; Reverse list.
-      (setq normalized (nreverse normalized)))
-     ;; The two cases below must come from the SPECIFIERS argument of
-     ;; `display-buffer'.
-     ((eq specifiers 't)
-      ;; Historically t means "other window".  Eventually we should get
-      ;; rid of this.
-      (setq normalized
-           (cdr (assq 'other-window display-buffer-macro-specifiers))
-           normalized))
-     ((symbolp specifiers)
-      ;; We allow scalar specifiers in calls of `display-buffer'.
-      (let ((entry (assq specifiers display-buffer-macro-specifiers)))
-       (when entry (setq normalized (cdr entry))))))
-
-    normalized))
+      (nreverse normalized))
+     ((setq entry (assq specifiers display-buffer-macro-specifiers))
+      ;; A macro specifier.
+      (cdr entry))
+     ((or (display-buffer-other-window-means-other-frame buffer-name label)
+         (with-no-warnings (not pop-up-frames)))
+      (cdr (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))))))
 
 (defun display-buffer-normalize-specifiers-2 (&optional buffer-or-name)
   "Subroutine of `display-buffer-normalize-specifiers'.
@@ -4952,8 +5022,13 @@ options."
         specifiers)
     ;; Disable warnings, there are too many obsolete options here.
     (with-no-warnings
+      ;; `even-window-heights', unless nil or unset.
+      (unless (memq even-window-heights '(nil unset))
+       (setq specifiers
+             (cons (cons 'reuse-window-even-sizes t) specifiers)))
+
       ;; `display-buffer-mark-dedicated'
-      (unless (memq display-buffer-mark-dedicated '(nil unset))
+      (when display-buffer-mark-dedicated
        (setq specifiers
              (cons (cons 'dedicate display-buffer-mark-dedicated)
                    specifiers)))
@@ -4985,10 +5060,21 @@ options."
                            (cons 'largest fun) (cons 'lru fun))
                      specifiers))))
 
-      ;; `pop-up-frame' group.  Anything is added here iff
-      ;; `pop-up-frames' is neither nil nor unset (we ignore the problem
-      ;; that callers usually don't care about graphic-only).
-      (unless (memq pop-up-frames '(nil unset))
+      ;; `special-display-p' group.
+      (when special-display-function
+       ;; `special-display-p' returns either t or a list of frame
+       ;; parameters to pass to `special-display-function'.
+       (let ((pars (special-display-p buffer-name)))
+         (when pars
+           (setq specifiers
+                 (cons (list 'fun-with-args special-display-function
+                             (when (listp pars) pars))
+                       specifiers)))))
+
+      ;; `pop-up-frame' group.  Add things if `pop-up-frames' is non-nil
+      ;; (we ignore the problem that callers usually don't care about
+      ;; graphic-only).
+      (when pop-up-frames
        ;; `pop-up-frame-function'.  If `pop-up-frame-function' uses the
        ;; now obsolete `pop-up-frame-alist' it will continue to do so.
        (setq specifiers
@@ -4998,163 +5084,39 @@ options."
        (setq specifiers
              (cons (list 'pop-up-frame pop-up-frames) specifiers)))
 
-      ;; `special-display-regexps'
-      (dolist (entry special-display-regexps)
-       (cond
-        ((stringp entry)
-         ;; Plain string.
-         (when (string-match-p entry buffer-name)
-           (setq specifiers
-                 (cons
-                  (list 'fun-with-args special-display-function
-                        special-display-frame-alist)
-                  specifiers))))
-        ((consp entry)
-         (let ((name (car entry))
-               (rest (cdr entry)))
-           (cond
-            ((not (string-match-p name buffer-name)))
-            ((functionp (car rest))
-             ;; A function.
-             (setq specifiers
-                   (cons (list 'fun-with-args (car rest) (cadr rest))
-                         specifiers)))
-            ((listp rest)
-             ;; A list of parameters.
-             (cond
-              ((assq 'same-window rest)
-               (setq specifiers
-                     (cons (list 'reuse-window 'same) specifiers))
-               (setq specifiers
-                     (cons (list 'reuse-window-dedicated 'weak)
-                           specifiers)))
-              ((assq 'same-frame rest)
-               (setq specifiers
-                     (setq specifiers
-                           (cons (list 'same-frame) specifiers))))
-              (t
-               (setq specifiers
-                     (cons (list 'fun-with-args special-display-function
-                                 special-display-frame-alist)
-                           specifiers))))))))))
-
-      ;; `special-display-buffer-names'
-      (dolist (entry special-display-buffer-names)
-       (cond
-        ((stringp entry)
-         ;; Plain string.
-         (when (string-equal entry buffer-name)
-           (setq specifiers
-                 (cons
-                  (list 'fun-with-args special-display-function
-                        special-display-frame-alist)
-                  specifiers))))
-        ((consp entry)
-         (let ((name (car entry))
-               (rest (cdr entry)))
-           (cond
-            ((not (string-equal name buffer-name)))
-            ((functionp (car rest))
-             ;; A function.
-             (setq specifiers
-                   (cons (list 'fun-with-args (car rest) (cadr rest))
-                         specifiers)))
-            ((listp rest)
-             ;; A list of parameters.
-             (cond
-              ((assq 'same-window rest)
-               (setq specifiers
-                     (cons (list 'reuse-window 'same) specifiers))
-               (setq specifiers
-                     (cons (list 'reuse-window-dedicated 'weak)
-                           specifiers)))
-              ((assq 'same-frame rest)
-               (setq specifiers
-                     (setq specifiers
-                           (cons (list 'same-frame) specifiers))))
-              (t
-               (setq specifiers
-                     (cons (list 'fun-with-args special-display-function
-                                 special-display-frame-alist)
-                           specifiers))))))))))
-
-      ;; `same-window-regexps'
-      (dolist (entry same-window-regexps)
-       (cond
-        ((stringp entry)
-         (when (string-match-p entry buffer-name)
-           (setq specifiers
-                 (cons (list 'reuse-window 'same) specifiers))))
-        ((consp entry)
-         (when (string-match-p (car entry) buffer-name)
-           (setq specifiers
-                 (cons (list 'reuse-window 'same) specifiers))))))
-
-      ;; `same-window-buffer-names'
-      (dolist (entry same-window-buffer-names)
-       (cond
-        ((stringp entry)
-         (when (string-equal entry buffer-name)
-           (setq specifiers
-                 (cons (list 'reuse-window 'same) specifiers))))
-        ((consp entry)
-         (when (string-equal (car entry) buffer-name)
-           (setq specifiers
-                 (cons (list 'reuse-window 'same) specifiers))))))
+      ;; `same-window-p' group.
+      (when (same-window-p buffer-name)
+       ;; Try to reuse the same (selected) window.
+       (setq specifiers
+             (cons (list 'reuse-window 'same nil nil)
+                   specifiers)))
 
-      ;; `pop-up-windows' and `pop-up-frames' nil means means we
+      ;; `pop-up-windows' and `pop-up-frames' both nil means means we
       ;; are supposed to reuse any window (unless we find one showing
       ;; the same buffer already).
-
-      ;; This clause is needed because Emacs 23 options can be used to
-      ;; suppress a certain behavior while `display-buffer-alist' can be
-      ;; only used to enforce some behavior.
-      (when (and (not pop-up-windows) (memq pop-up-frames '(nil unset)))
-       ;; `even-window-heights'
-       (when even-window-heights
-         (setq specifiers
-               (cons (cons 'reuse-window-even-sizes t) specifiers)))
+      (unless (or pop-up-windows pop-up-frames)
        ;; `reuse-window' showing any buffer on same frame.
        (setq specifiers
              (cons (list 'reuse-window nil nil nil)
                    specifiers)))
 
-      ;; `display-buffer-reuse-frames' or `pop-up-frames' set means we
-      ;; are supposed to reuse a window showing the same buffer.
-      (unless (and (memq display-buffer-reuse-frames '(nil unset))
-                  (memq pop-up-frames '(nil unset)))
-       ;; `even-window-heights'
-       (when even-window-heights
-         (setq specifiers
-               (cons (cons 'reuse-window-even-sizes t) specifiers)))
+      ;; `display-buffer-reuse-frames' or `pop-up-frames' non-nil means
+      ;; we are supposed to reuse a window showing the same buffer on
+      ;; another frame.
+      (when (or display-buffer-reuse-frames pop-up-frames)
        ;; `reuse-window' showing same buffer on visible frame.
        (setq specifiers
-             (cons (list 'reuse-window nil 'same 0)
-                   specifiers)))
+             (cons (list 'reuse-window nil 'same 0) specifiers)))
 
-      specifiers)))
-
-(defun display-buffer-normalize-specifiers (buffer-name specifiers label)
-  "Return normalized specifiers for a buffer matching BUFFER-NAME or LABEL.
-BUFFER-NAME must be a string specifying a valid buffer name.
-SPECIFIERS and LABEL are the homonymous arguments of
-`display-buffer'.
+      ;; Prepend "reuse window on same frame if showing the buffer
+      ;; already" specifier.
+      (setq specifiers (cons (list 'reuse-window nil 'same nil)
+                            specifiers))
 
-The method for displaying the buffer specified by BUFFER-NAME or
-LABEL is established by appending the following four lists of
-specifiers:
-
-- The specifiers in `display-buffer-alist' whose buffer
-  identifier matches BUFFER-NAME or LABEL and whose 'override
-  component is set.
-
-- SPECIFIERS.
-
-- The specifiers in `display-buffer-alist' whose buffer
-  identifier matches BUFFER-NAME or LABEL and whose 'override
-  component is not set.
+      specifiers)))
 
-- `display-buffer-default-specifiers'."
+(defun display-buffer-normalize-specifiers-3 (buffer-name label)
+  "Subroutine of `display-buffer-normalize-specifiers'."
   (let (list-1 list-2)
     (dolist (entry display-buffer-alist)
       (when (and (listp entry)
@@ -5170,7 +5132,8 @@ specifiers:
                                   (and (eq type 'label) (eq value label)))
                           (throw 'match t)))))))
        (let* ((raw (cdr entry))
-              (normalized (display-buffer-normalize-specifiers-1 raw)))
+              (normalized
+               (display-buffer-normalize-specifiers-1 raw buffer-name label)))
          (if (assq 'override raw)
              (setq list-1
                    (if list-1
@@ -5181,15 +5144,39 @@ specifiers:
                      (append list-2 normalized)
                    normalized))))))
 
+    (cons list-1 list-2)))
+
+(defun display-buffer-normalize-specifiers (buffer-name specifiers label)
+  "Return normalized specifiers for a buffer matching BUFFER-NAME or LABEL.
+BUFFER-NAME must be a string specifying a valid buffer name.
+SPECIFIERS and LABEL are the homonymous arguments of
+`display-buffer'.
+
+The method for displaying the buffer specified by BUFFER-NAME or
+LABEL is established by appending the following four lists of
+specifiers:
+
+- The specifiers in `display-buffer-alist' whose buffer
+  identifier matches BUFFER-NAME or LABEL and whose 'override
+  component is set.
+
+- SPECIFIERS.
+
+- The specifiers in `display-buffer-alist' whose buffer
+  identifier matches BUFFER-NAME or LABEL and whose 'override
+  component is not set.
+
+- `display-buffer-default-specifiers'."
+  (let* ((list (display-buffer-normalize-specifiers-3 buffer-name label)))
     (append
      ;; Overriding user specifiers.
-     list-1
+     (car list)
      ;; Application specifiers.
-     (display-buffer-normalize-specifiers-1 specifiers)
+     (display-buffer-normalize-specifiers-1 specifiers buffer-name label)
      ;; Emacs 23 compatibility specifiers.
      (display-buffer-normalize-specifiers-2 buffer-name)
      ;; Non-overriding user specifiers.
-     list-2
+     (cdr list)
      ;; Default specifiers.
      display-buffer-default-specifiers)))
 
@@ -5305,10 +5292,10 @@ this list as arguments."
          (display-buffer-reuse-window buffer '(nil other 0))
          ;; Try making a new frame.
          (display-buffer-pop-up-frame buffer)
-         ;; Try using weakly dedicated windows.
+         ;; Try using a weakly dedicated window.
          (display-buffer-reuse-window
           buffer '(nil nil t) '((reuse-window-dedicated . weak)))
-         ;; Try using strongly dedicated windows.
+         ;; Try using a strongly dedicated window.
          (display-buffer-reuse-window
           buffer '(nil nil t) '((reuse-window-dedicated . t)))))))
 
@@ -5515,8 +5502,8 @@ functions should call `pop-to-buffer-same-window' instead."
 (defun switch-to-buffer-same-frame (buffer-or-name &optional norecord)
   "Switch to buffer BUFFER-OR-NAME in a window on the selected frame.
 Another frame will be used only if there is no other choice.
-Optional arguments BUFFER-OR-NAME and NORECORD have the same
-meaning as for `switch-to-buffer'.
+Arguments BUFFER-OR-NAME and NORECORD have the same meaning as
+for `switch-to-buffer'.
 
 This function is intended for interactive use only.  Lisp
 functions should call `pop-to-buffer-same-frame' instead."
@@ -5529,8 +5516,8 @@ functions should call `pop-to-buffer-same-frame' instead."
   "Switch to buffer BUFFER-OR-NAME in another window.
 The selected window will be used only if there is no other
 choice.  Windows on the selected frame are preferred to windows
-on other frames.  Optional arguments BUFFER-OR-NAME and NORECORD
-have the same meaning as for `switch-to-buffer'.
+on other frames.  Arguments BUFFER-OR-NAME and NORECORD have the
+same meaning as for `switch-to-buffer'.
 
 This function is intended for interactive use only.  Lisp
 functions should call `pop-to-buffer-other-window' instead."
@@ -5542,8 +5529,8 @@ functions should call `pop-to-buffer-other-window' instead."
 (defun switch-to-buffer-other-window-same-frame (buffer-or-name &optional norecord)
   "Switch to buffer BUFFER-OR-NAME in another window on the selected frame.
 The selected window or another frame will be used only if there
-is no other choice.  Optional arguments BUFFER-OR-NAME and
-NORECORD have the same meaning as for `switch-to-buffer'.
+is no other choice.  Arguments BUFFER-OR-NAME and NORECORD have
+the same meaning as for `switch-to-buffer'.
 
 This function is intended for interactive use only.  Lisp
 functions should call `pop-to-buffer-other-window-same-frame'
@@ -5556,8 +5543,8 @@ instead."
 (defun switch-to-buffer-other-frame (buffer-or-name &optional norecord)
   "Switch to buffer BUFFER-OR-NAME on another frame.
 The same frame will be used only if there is no other choice.
-Optional arguments BUFFER-OR-NAME and NORECORD have the same
-meaning as for `switch-to-buffer'.
+Arguments BUFFER-OR-NAME and NORECORD have the same meaning
+as for `switch-to-buffer'.
 
 This function is intended for interactive use only.  Lisp
 functions should call `pop-to-buffer-other-frame' instead."
@@ -5583,7 +5570,7 @@ See also `same-window-regexps'."
  :group 'windows)
 (make-obsolete-variable
  'same-window-buffer-names
- "use `display-buffer-alist' or 2nd arg of `display-buffer' instead." "24.1")
+ "use 2nd arg of `display-buffer' instead." "24.1")
 
 (defcustom same-window-regexps nil
   "List of regexps saying which buffers should appear in the \"same\" window.
@@ -5601,7 +5588,7 @@ See also `same-window-buffer-names'."
   :group 'windows)
 (make-obsolete-variable
  'same-window-regexps
- "use `display-buffer-alist' or 2nd arg of `display-buffer' instead." "24.1")
+ "use 2nd arg of `display-buffer' instead." "24.1")
 
 (defun same-window-p (buffer-name)
   "Return non-nil if a buffer named BUFFER-NAME would be shown in the \"same\" window.
@@ -5609,8 +5596,8 @@ This function returns non-nil if `display-buffer' or
 `pop-to-buffer' would show a buffer named BUFFER-NAME in the
 selected rather than \(as usual\) some other window.  See
 `same-window-buffer-names' and `same-window-regexps'."
-  (let ((buffer-names (with-no-warnings special-display-buffer-names))
-       (regexps (with-no-warnings special-display-regexps)))
+  (let ((buffer-names (with-no-warnings same-window-buffer-names))
+       (regexps (with-no-warnings same-window-regexps)))
     (cond
      ((not (stringp buffer-name)))
      ;; The elements of `same-window-buffer-names' can be buffer
@@ -5647,7 +5634,7 @@ These supersede the values given in `default-frame-alist'."
   :group 'frames)
 (make-obsolete-variable
  'special-display-frame-alist
- "use `display-buffer-alist' or 2nd arg of `display-buffer' instead." "24.1")
+ "use 2nd arg of `display-buffer' instead." "24.1")
 
 (defun special-display-popup-frame (buffer &optional args)
   "Display BUFFER in a special frame and return the window chosen.
@@ -5695,7 +5682,7 @@ and (cdr ARGS) as second."
         (frame-selected-window frame))))))
 (make-obsolete
  'special-display-popup-frame
- "use `display-buffer-alist' or 2nd arg of `display-buffer' instead." "24.1")
+ "use 2nd arg of `display-buffer' instead." "24.1")
 
 (defcustom special-display-function 'special-display-popup-frame
   "Function to call for displaying special buffers.
@@ -5714,7 +5701,7 @@ A buffer is special when its name is either listed in
   :group 'frames)
 (make-obsolete-variable
  'special-display-function
- "use `display-buffer-alist' or 2nd arg of `display-buffer' instead." "24.1")
+ "use 2nd arg of `display-buffer' instead." "24.1")
 
 (defcustom special-display-buffer-names nil
   "List of names of buffers that should be displayed specially.
@@ -5781,7 +5768,7 @@ See also `special-display-regexps'."
   :group 'frames)
 (make-obsolete-variable
  'special-display-buffer-names
- "use `display-buffer-alist' or 2nd arg of `display-buffer' instead." "24.1")
+ "use 2nd arg of `display-buffer' instead." "24.1")
 
 ;;;###autoload
 (put 'special-display-buffer-names 'risky-local-variable t)
@@ -5852,7 +5839,7 @@ See also `special-display-buffer-names'."
   :group 'frames)
 (make-obsolete-variable
  'special-display-regexps
- "use `display-buffer-alist' or 2nd arg of `display-buffer' instead." "24.1")
+ "use 2nd arg of `display-buffer' instead." "24.1")
 
 (defun special-display-p (buffer-name)
   "Return non-nil if a buffer named BUFFER-NAME gets a special frame.
@@ -5904,7 +5891,7 @@ affected by this variable."
   :group 'frames)
 (make-obsolete-variable
  'pop-up-frame-alist
- "use `display-buffer-alist' or 2nd arg of `display-buffer' instead." "24.1")
+ "use 2nd arg of `display-buffer' instead." "24.1")
 
 (defcustom pop-up-frame-function
   (lambda () (make-frame pop-up-frame-alist))
@@ -5916,39 +5903,35 @@ frame.  The default value calls `make-frame' with the argument
   :group 'frames)
 (make-obsolete-variable
  'pop-up-frame-function
- "use `display-buffer-alist' or 2nd arg of `display-buffer' instead." "24.1")
+ "use 2nd arg of `display-buffer' instead." "24.1")
 
-(defcustom pop-up-frames 'unset ; nil
+(defcustom pop-up-frames nil
   "Whether `display-buffer' should make a separate frame.
 If nil, never make a separate frame.
 If the value is `graphic-only', make a separate frame
 on graphic displays only.
-If this is the symbol unset, the option was not set and is
-ignored.
 Any other non-nil value means always make a separate frame."
   :type '(choice
-         (const :tag "Unset" unset)
          (const :tag "Never" nil)
          (const :tag "On graphic displays only" graphic-only)
          (const :tag "Always" t))
-  :version "24.1"
   :group 'windows
   :group 'frames)
 (make-obsolete-variable
  'pop-up-frames
- "use `display-buffer-alist' or 2nd arg of `display-buffer' instead." "24.1")
+ "use 2nd arg of `display-buffer' instead." "24.1")
 
-(defcustom display-buffer-reuse-frames 'unset ; nil
+(defcustom display-buffer-reuse-frames nil
   "Set and non-nil means `display-buffer' should reuse frames.
 If the buffer in question is already displayed in a frame, raise
 that frame."
   :type 'boolean
-  :version "24.1"
+  :version "21.1"
   :group 'windows
   :group 'frames)
 (make-obsolete-variable
  'display-buffer-reuse-frames
- "use `display-buffer-alist' or 2nd arg of `display-buffer' instead." "24.1")
+ "use 2nd arg of `display-buffer' instead." "24.1")
 
 (defcustom pop-up-windows 'unset ; t
   "Set and non-nil means `display-buffer' should make a new window."
@@ -5957,7 +5940,7 @@ that frame."
   :group 'windows)
 (make-obsolete-variable
  'pop-up-windows
- "use `display-buffer-alist' or 2nd arg of `display-buffer' instead." "24.1")
+ "use 2nd arg of `display-buffer' instead." "24.1")
 
 (defcustom split-window-preferred-function 'split-window-sensibly
   "Function called by `display-buffer' to split a window.
@@ -5986,7 +5969,7 @@ not want to split the selected window."
   :group 'windows)
 (make-obsolete-variable
  'split-window-preferred-function
- "use `display-buffer-alist' or 2nd arg of `display-buffer' instead." "24.1")
+ "use 2nd arg of `display-buffer' instead." "24.1")
 
 (defcustom split-height-threshold 80
   "Minimum height for splitting a window to display a buffer.
@@ -6000,7 +5983,7 @@ split it vertically disregarding the value of this variable."
   :group 'windows)
 (make-obsolete-variable
  'split-height-threshold
- "use `display-buffer-alist' or 2nd arg of `display-buffer' instead." "24.1")
+ "use 2nd arg of `display-buffer' instead." "24.1")
 
 (defcustom split-width-threshold 160
   "Minimum width for splitting a window to display a buffer.
@@ -6012,27 +5995,27 @@ is nil, `display-buffer' cannot split windows horizontally."
   :group 'windows)
 (make-obsolete-variable
  'split-width-threshold
- "use `display-buffer-alist' or 2nd arg of `display-buffer' instead." "24.1")
+ "use 2nd arg of `display-buffer' instead." "24.1")
 
-(defcustom even-window-heights t
-  "If non-nil `display-buffer' will try to even window heights.
+(defcustom even-window-heights 'unset ; t
+  "If set and non-nil `display-buffer' will try to even window heights.
 Otherwise `display-buffer' will leave the window configuration
 alone.  Heights are evened only when `display-buffer' reuses a
 window that appears above or below the selected window."
   :type 'boolean
-  :version "23.1"
+  :version "24.1"
   :group 'windows)
 (make-obsolete-variable
  'even-window-heights
- "use `display-buffer-alist' or 2nd arg of `display-buffer' instead." "24.1")
+ "use 2nd arg of `display-buffer' instead." "24.1")
 
-(defvar display-buffer-mark-dedicated 'unset ; nil
-  "Set and non-nil means `display-buffer' marks the windows it creates as dedicated.
+(defvar display-buffer-mark-dedicated nil
+  "Non-nil means `display-buffer' marks the windows it creates as dedicated.
 The actual non-nil value of this variable will be copied to the
 `window-dedicated-p' flag.")
 (make-obsolete-variable
  'display-buffer-mark-dedicated
- "use `display-buffer-alist' or 2nd arg of `display-buffer' instead." "24.1")
+ "use 2nd arg of `display-buffer' instead." "24.1")
 
 (defun window-splittable-p (window &optional horizontal)
   "Return non-nil if `split-window-sensibly' may split WINDOW.
@@ -6204,7 +6187,7 @@ value of `display-buffer-alist'."
      nil
      (list
       'pop-up-frame
-      (unless (memq pop-up-frames '(nil unset))
+      (when pop-up-frames
        (list 'pop-up-frame pop-up-frames))
       (when pop-up-frame-function
        (cons 'pop-up-frame-function pop-up-frame-function))
@@ -6340,17 +6323,16 @@ value of `display-buffer-alist'."
      (list
       'reuse-window
       (list 'reuse-window nil 'same
-           (unless (and (memq display-buffer-reuse-frames '(nil unset))
-                        (memq pop-up-frames '(nil unset)))
+           (when (or display-buffer-reuse-frames pop-up-frames)
              ;; "0" (all visible and iconified frames) is hardcoded in
              ;; Emacs 23.
                0))
-      (when even-window-heights
+      (unless (memq even-window-heights '(nil unset))
        (cons 'reuse-window-even-sizes t)))
      no-custom)
 
     ;; `display-buffer-mark-dedicated'
-    (unless (memq display-buffer-mark-dedicated '(nil unset))
+    (when display-buffer-mark-dedicated
       (display-buffer-alist-add
        nil
        (list