emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r105058: Simplify normalization of de


From: martin rudalics
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r105058: Simplify normalization of default buffer display specifieres and options.
Date: Sat, 09 Jul 2011 14:32:38 +0200
User-agent: Bazaar (2.3.1)

------------------------------------------------------------
revno: 105058
committer: martin rudalics <address@hidden>
branch nick: trunk
timestamp: Sat 2011-07-09 14:32:38 +0200
message:
  Simplify normalization of default buffer display specifieres and options.
  
  * window.el (display-buffer-default-specifiers): Remove.
  (display-buffer-macro-specifiers): Remove default specifiers.
  (display-buffer-alist): Default to nil.
  (display-buffer-reuse-window): New optional argument
  other-window.
  (display-buffer-pop-up-window): Allow splitting internal
  windows.  Check whether a live window was created.
  (display-buffer-other-window-means-other-frame)
  (display-buffer-normalize-arguments): Rename to
  display-buffer-normalize-argument and rewrite.  Set the
  other-window specifier.
  (display-buffer-normalize-special): New function.
  (display-buffer-normalize-options): Rename to
  display-buffer-normalize-default and rewrite.
  (display-buffer-normalize-options-inhibit): Remove.
  (display-buffer-normalize-specifiers): Rewrite.
  (display-buffer): Process other-window specifier and call
  display-buffer-reuse-window with it.  Emulate Emacs 23 behavior
  more faithfully.
  (pop-up-windows, even-window-heights): Restore Emacs 23 default
  values.
  (display-buffer-alist-set): Don't handle 'unset default values.
  (display-buffer-in-window, display-buffer-alist-set): Replace
  symbol "dedicated" by "dedicate".  Reported by Tassilo Horn
  <address@hidden>.
modified:
  lisp/ChangeLog
  lisp/window.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2011-07-09 03:11:57 +0000
+++ b/lisp/ChangeLog    2011-07-09 12:32:38 +0000
@@ -1,3 +1,31 @@
+2011-07-09  Martin Rudalics  <address@hidden>
+
+       * window.el (display-buffer-default-specifiers): Remove.
+       (display-buffer-macro-specifiers): Remove default specifiers.
+       (display-buffer-alist): Default to nil.
+       (display-buffer-reuse-window): New optional argument
+       other-window.
+       (display-buffer-pop-up-window): Allow splitting internal
+       windows.  Check whether a live window was created.
+       (display-buffer-other-window-means-other-frame)
+       (display-buffer-normalize-arguments): Rename to
+       display-buffer-normalize-argument and rewrite.  Set the
+       other-window specifier.
+       (display-buffer-normalize-special): New function.
+       (display-buffer-normalize-options): Rename to
+       display-buffer-normalize-default and rewrite.
+       (display-buffer-normalize-options-inhibit): Remove.
+       (display-buffer-normalize-specifiers): Rewrite.
+       (display-buffer): Process other-window specifier and call
+       display-buffer-reuse-window with it.  Emulate Emacs 23 behavior
+       more faithfully.
+       (pop-up-windows, even-window-heights): Restore Emacs 23 default
+       values.
+       (display-buffer-alist-set): Don't handle 'unset default values.
+       (display-buffer-in-window, display-buffer-alist-set): Replace
+       symbol "dedicated" by "dedicate".  Reported by Tassilo Horn
+       <address@hidden>.
+
 2011-07-09  Leo Liu  <address@hidden>
 
        * register.el (insert-register): Restore accidental change on
@@ -42,6 +70,9 @@
        The order of searching the available programs is the same as in
        `archive-zip-extract' (bug#8968).
 
+2011-07-07  Lars Magne Ingebrigtsen  <address@hidden>
+
+       * cus-edit.el (custom-show): Marked as obsolete.
 2011-07-07  Chong Yidong  <address@hidden>
 
        * menu-bar.el (menu-bar-line-wrapping-menu): Revert last change.

=== modified file 'lisp/window.el'
--- a/lisp/window.el    2011-07-07 01:46:59 +0000
+++ b/lisp/window.el    2011-07-09 12:32:38 +0000
@@ -3829,22 +3829,6 @@
        (window-state-put-2 ignore))
       (window-check frame))))
 
-;;; Displaying buffers.
-(defconst display-buffer-default-specifiers
-  '((reuse-window nil same visible)
-    (pop-up-window (largest . nil) (lru . nil))
-    (pop-up-window-min-height . 40)
-    (pop-up-window-min-width . 80)
-    (reuse-window other nil nil)
-    (reuse-window nil other visible)
-    (reuse-window nil nil t)
-    (reuse-window-even-sizes . t))
-  "Buffer display default specifiers.
-The value specified here is used when no other specifiers have
-been specified by the user or the application.  Consult the
-documentation of `display-buffer-alist' for a description of
-buffer display specifiers.")
-
 (defconst display-buffer-macro-specifiers
   '((same-window
      ;; Use the same window.
@@ -3854,11 +3838,6 @@
      (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))
-    ;;  (reuse-window other other visible))
     (same-frame-other-window
      ;; Avoid other frames and selected window.
      (reuse-window other same nil)
@@ -3868,25 +3847,10 @@
      ;; Avoid selected frame.
      (reuse-window nil same other)
      (pop-up-frame)
-     (reuse-window nil other other))
-    (default
-      ;; The default specifiers.
-      display-buffer-default-specifiers))
+     (reuse-window nil other other)))
   "Buffer display macro specifiers.")
 
-(defcustom display-buffer-alist
-  '((((regexp . ".*"))
-     ;; Reuse window showing same buffer on same frame.
-     reuse-window (reuse-window nil same nil)
-     ;; Pop up window.
-     pop-up-window
-     ;; Split largest or lru window.
-     (pop-up-window (largest . nil) (lru . nil))
-     (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)))
+(defcustom display-buffer-alist nil
   "List associating buffer identifiers with display specifiers.
 The car of each element of this list is built from a set of cons
 cells called buffer identifiers.  `display-buffer' shows a buffer
@@ -4751,15 +4715,15 @@
   (setq window (window-normalize-live-window window))
   (let* ((old-frame (selected-frame))
         (new-frame (window-frame window))
-        (dedicated (cdr (assq 'dedicated specifiers)))
+        (dedicate (cdr (assq 'dedicate specifiers)))
         (no-other-window (cdr (assq 'no-other-window specifiers))))
     ;; Show BUFFER in WINDOW.
     (unless (eq buffer (window-buffer window))
       ;; If we show another buffer in WINDOW, undedicate it first.
       (set-window-dedicated-p window nil))
     (set-window-buffer window buffer)
-    (when dedicated
-      (set-window-dedicated-p window dedicated))
+    (when dedicate
+      (set-window-dedicated-p window dedicate))
     (when no-other-window
       (set-window-parameter window 'no-other-window t))
     (unless (or (eq old-frame new-frame)
@@ -4775,7 +4739,7 @@
     ;; Return window.
     window))
 
-(defun display-buffer-reuse-window (buffer method &optional specifiers)
+(defun display-buffer-reuse-window (buffer method &optional specifiers 
other-window)
   "Display BUFFER in an existing window.
 METHOD must be a list in the form of the cdr of a `reuse-window'
 buffer display specifier, see `display-buffer-alist' for an
@@ -4787,8 +4751,9 @@
 frame.
 
 Optional argument SPECIFIERS must be a list of valid display
-specifiers.  Return the window chosen to display BUFFER, nil if
-none was found."
+specifiers.  Optional argument OTHER-WINDOW, if non-nil, means do
+not use the selected window.  Return the window chosen to display
+BUFFER, nil if none was found."
   (let* ((method-window (nth 0 method))
         (method-buffer (nth 1 method))
         (method-frame (nth 2 method))
@@ -4806,6 +4771,7 @@
                       (eq window-buffer buffer))
                   (or (not method-window)
                       (and (eq method-window 'same)
+                           (not other-window)
                            (eq window (selected-window)))
                       (and (eq method-window 'other)
                            (not (eq window (selected-window))))
@@ -5064,7 +5030,7 @@
                  ;; A window, directly specified.
                  cand)))
 
-         (when (and (window-live-p window)
+         (when (and (window-any-p window)
                     ;; The window must be on the correct frame,
                     (eq (window-frame window) frame)
                     ;; and must be neither a minibuffer window
@@ -5084,7 +5050,7 @@
                      ;; Don't pass any specifiers to this function.
                      (funcall side window)))))
 
-           (when window
+           (when (window-live-p window)
              ;; Adjust sizes if asked for.
              (display-buffer-set-height window specifiers)
              (display-buffer-set-width window specifiers)
@@ -5324,201 +5290,225 @@
 
 The calculation of the return value is exclusively based on the
 user preferences expressed in `display-buffer-alist'."
-  (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.
+        '((dedicated . nil)))
+       `((pop-up-frame t)
+        ,(append '(pop-up-frame-alist)
+                 (when (listp args) args)
+                 special-display-frame-alist)
+        (dedicated . t))))))
+
+(defun display-buffer-normalize-default (buffer-or-name)
   "Subroutine of `display-buffer-normalize-specifiers'.
-BUFFER-OR-NAME is the buffer to display.  This routine provides a
-compatibility layer for the now obsolete Emacs 23 buffer display
-options."
-  (with-no-warnings
+BUFFER-OR-NAME is the buffer to display.
+
+This routine provides a compatibility layer for the obsolete
+Emacs 23 buffer display options to set up the corresponding
+buffer display specifiers."
+  (progn ;; <-- reserved for with-no-warnings
     (let* ((buffer (window-normalize-buffer buffer-or-name))
           (buffer-name (buffer-name buffer))
-          (use-pop-up-frames
-           (or (and (eq pop-up-frames 'graphic-only)
-                    (display-graphic-p))
-               pop-up-frames))
-          specifiers)
-      ;; `even-window-heights', unless nil or unset.
-      (unless (memq even-window-heights '(nil unset))
+          (pop-up-frames
+           (and (boundp 'pop-up-frames)
+                (or (and (eq pop-up-frames 'graphic-only)
+                         (display-graphic-p))
+                    pop-up-frames)))
+          specifiers args)
+      ;; `other-window-means-other-frame'
+      (when pop-up-frames
+       (setq specifiers
+             (cons (cons 'other-window-means-other-frame t) specifiers)))
+
+      ;; `even-window-heights'
+      (unless (and (boundp 'even-window-heights)
+                  (not even-window-heights))
        (setq specifiers
              (cons (cons 'reuse-window-even-sizes t) specifiers)))
 
       ;; `display-buffer-mark-dedicated'
-      (when display-buffer-mark-dedicated
+      (when (and (boundp 'display-buffer-mark-dedicated)
+                display-buffer-mark-dedicated)
        (setq specifiers
              (cons (cons 'dedicate display-buffer-mark-dedicated)
                    specifiers)))
 
-      ;; `pop-up-window' group.  Anything is added here iff
-      ;; `pop-up-windows' is neither nil nor unset.
-      (let ((pop-up-window (not (memq pop-up-windows '(nil unset))))
-           (fun (unless (eq split-window-preferred-function
-                            'split-window-sensibly)
-                  split-window-preferred-function))
-           (min-height (if (numberp split-height-threshold)
-                           (/ split-height-threshold 2)
-                         1.0))
-           (min-width (if (numberp split-width-threshold)
-                          (/ split-width-threshold 2)
-                        1.0)))
-       ;; Create an entry only if a default value was changed.
-       (when (or pop-up-window
-                 (not (equal split-height-threshold 80))
-                 (not (equal split-width-threshold 160)))
-         ;; `reuse-window' (needed as fallback when popping up the new
-         ;; window fails).
-         (setq specifiers
-               (cons (list 'reuse-window 'other nil nil)
-                     specifiers))
-         ;; `split-width-threshold'
-         (setq specifiers
-               (cons (cons 'pop-up-window-min-width min-width)
-                     specifiers))
-         ;; `split-height-threshold'
-         (setq specifiers
-               (cons (cons 'pop-up-window-min-height min-height)
-                     specifiers))
+      ;; `pop-up-window-min-height'
+      (let ((min-height
+            (if (boundp 'split-height-threshold)
+                (if (numberp split-height-threshold)
+                    (/ split-height-threshold 2)
+                  1.0)
+              40)))
+       (setq specifiers
+             (cons (cons 'pop-up-window-min-height min-height)
+                   specifiers)))
+
+      ;; `pop-up-window-min-width'
+      (let ((min-width
+            (if (boundp 'split-width-threshold)
+                (if (numberp split-width-threshold)
+                    (/ split-width-threshold 2)
+                  1.0)
+              80)))
+       (setq specifiers
+             (cons (cons 'pop-up-window-min-width min-width)
+                   specifiers)))
+
+      ;; `pop-up-window'
+      (unless (and (boundp 'pop-up-windows) (not pop-up-windows))
+       (let ((fun (when (and (boundp 'split-window-preferred-function)
+                             (not (eq split-window-preferred-function
+                                      'split-window-sensibly)))
+                    split-window-preferred-function)))
          ;; `pop-up-window'
          (setq specifiers
-               (cons (list 'pop-up-window
-                           (cons 'largest fun) (cons 'lru fun))
-                     specifiers))))
-
-      ;; `pop-up-frame' group.
-      (when use-pop-up-frames
+               (cons
+                (list 'pop-up-window (cons 'largest fun) (cons 'lru fun))
+                specifiers))))
+
+      ;; `pop-up-frame-function'
+      (when (and (boundp 'pop-up-frame-function)
+                (not (equal pop-up-frame-function
+                            '(lambda nil
+                               (make-frame pop-up-frame-alist)))))
+       (setq specifiers
+             (cons (cons 'pop-up-frame-function pop-up-frame-function)
+                   specifiers)))
+
+      ;; `pop-up-frame-alist'
+      (when pop-up-frame-alist
+       (setq specifiers
+             (cons (cons 'pop-up-frame-alist pop-up-frame-alist)
+                   specifiers)))
+
+      ;; `pop-up-frame'
+      (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
-             (cons (cons 'pop-up-frame-function pop-up-frame-function)
-                   specifiers))
        ;; `pop-up-frame'
        (setq specifiers
+             ;; Maybe we should merge graphic-only into the following?
              (cons (list 'pop-up-frame t) specifiers)))
 
-      ;; `pop-up-windows' and `use-pop-up-frames' both nil means means
-      ;; we are supposed to reuse any window on the same frame (unless
-      ;; we find one showing the same buffer already).
-      (unless (or pop-up-windows use-pop-up-frames)
-       ;; `reuse-window' showing any buffer on same frame.
-       (setq specifiers
-             (cons (list 'reuse-window nil nil nil)
-                   specifiers)))
-
-      ;; `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
+      ;; `special-display'
+      (when (and (boundp 'special-display-function)
+                special-display-function
+                (fboundp 'special-display-p)
+                (setq args (special-display-p buffer-name)))
+       ;; `special-display-p' returns either t or a list of arguments
+       ;; to pass to `special-display-function'.
+       (if (eq special-display-function 'special-display-popup-frame)
            (setq specifiers
-                 (cons (list 'function special-display-function
-                             (when (listp pars) pars))
-                       specifiers)))))
+                 (append (display-buffer-normalize-special args)
+                         specifiers))
+         (setq specifiers
+               (cons
+                `(function ,special-display-function ,(when (listp args) args))
+                specifiers))))
 
+      ;; Reuse window showing same buffer on visible or iconified frame.
       ;; `pop-up-frames', `display-buffer-reuse-frames' means search for
       ;; a window showing the buffer on some visible or iconfied frame.
-      ;; `last-nonminibuffer-frame' set and not the same frame means
-      ;; search that frame.
-      (let ((frames (or (and (or use-pop-up-frames
-                                display-buffer-reuse-frames
+      ;; `last-nonminibuffer-frame' non-nil means search that frame.
+      (let ((frames (or (and (or pop-up-frames
+                                (and (boundp 'display-buffer-reuse-frames)
+                                     display-buffer-reuse-frames)
                                 (not (last-nonminibuffer-frame)))
                             ;; All visible or iconfied frames.
                             0)
-                       ;; Same frame.
+                       ;; The following usually returns the same frame
+                       ;; so we implicitly search for a window showing
+                       ;; the buffer on the same frame already.
                        (last-nonminibuffer-frame))))
        (when frames
          (setq specifiers
                (cons (list 'reuse-window 'other 'same frames)
                      specifiers))))
 
-      ;; `same-window-p' group.
-      (when (same-window-p buffer-name)
+      ;; `same-window'
+      (when (and (fboundp 'same-window-p) (same-window-p buffer-name))
        ;; Try to reuse the same (selected) window.
        (setq specifiers
-             (cons (list 'reuse-window 'same nil nil)
-                   specifiers)))
+             (cons (list 'reuse-window 'same nil nil) specifiers)))
 
-      ;; Prepend "reuse window on same frame if showing the buffer
-      ;; already" specifier.  It will be overriden by the application
-      ;; supplied 'other-window specifier.
-      (setq specifiers (cons (list 'reuse-window nil 'same nil)
-                            specifiers))
+      ;; Same window if showing this buffer already.  Can be overridden
+      ;; by `other-window' argument if the buffer is already shown in
+      ;; the same window.
+      (setq specifiers
+           (cons (list 'reuse-window 'same 'same nil) specifiers))
 
       specifiers)))
 
+(defun display-buffer-normalize-argument (buffer-name specifiers 
other-window-means-other-frame)
+  "Normalize second argument of `display-buffer'.
+BUFFER-NAME is the name of the buffer that shall be displayed,
+SPECIFIERS is the second argument of `display-buffer'.
+OTHER-WINDOW-MEANS-OTHER-FRAME non-nil means use other-frame for
+other-window."
+  (progn ;; <-- reserved for with-no-warnings
+    (let (normalized entry specifier pars)
+      (cond
+       ((not specifiers)
+       nil)
+       ((listp specifiers)
+       ;; If SPECIFIERS is a list, we assume it is a list of valid
+       ;; 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-window-means-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))
+       (t
+       ;; Anything else means use another window according to the
+       ;; non-overriding specifiers of `display-buffer-alist' and the
+       ;; specifiers produced by `display-buffer-normalize-default'.
+       '((other-window . t)))))))
+
 (defun display-buffer-normalize-alist-1 (specifiers label)
   "Subroutine of `display-buffer-normalize-alist'.
 SPECIFIERS is a list of buffer display specfiers.  LABEL is the
@@ -5579,9 +5569,6 @@
 
     (cons list-1 list-2)))
 
-(defvar display-buffer-normalize-options-inhibit nil
-  "If non-nil, `display-buffer' doesn't process obsolete options.")
-
 (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.
@@ -5600,25 +5587,33 @@
 
 - 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-alist buffer-name label))
-        (other-frame (cdr (assq 'other-window-means-other-frame
-                                (or (car list) (cdr list))))))
+  component is not set."
+  (let* ((default (display-buffer-normalize-default buffer-name))
+        (alist (display-buffer-normalize-alist buffer-name label))
+        (other-window-means-other-frame
+         (or (cdr (assq 'other-window-means-other-frame default))
+             (cdr (assq 'other-window-means-other-frame (cdr alist)))))
+        (arg2 (display-buffer-normalize-argument
+               buffer-name specifiers other-window-means-other-frame))
+        (arg3
+         ;; Handle special meaning of the LABEL argument of
+         ;; `display-buffer'.
+         (when (or (memq label '(visible 0 t)) (frame-live-p label))
+           ;; LABEL must be one of visible (any visible frame), 0 (any
+           ;; visible or iconfied frame), t (any frame), or a live
+           ;; frame.
+           `((reuse-window nil same ,label)))))
     (append
      ;; Overriding user specifiers.
-     (car list)
-     ;; Application specifiers.
-     (display-buffer-normalize-arguments
-      buffer-name specifiers label other-frame)
-     ;; Emacs 23 compatibility specifiers.
-     (unless display-buffer-normalize-options-inhibit
-       (display-buffer-normalize-options buffer-name))
+     (car alist)
+     ;; Special value of third argument of display-buffer.
+     arg3
+     ;; Second argument of display-buffer.
+     arg2
      ;; Non-overriding user specifiers.
-     (cdr list)
+     (cdr alist)
      ;; Default specifiers.
-     display-buffer-default-specifiers)))
+     default)))
 
 ;; Minibuffer-only frames should be documented better.  They really
 ;; deserve a separate section in the manual.  Also
@@ -5653,9 +5648,8 @@
 display location specifier or t, where the latter means to
 display the buffer in any but the selected window.  If SPECIFIERS
 is nil or omitted, this means to exclusively use the specifiers
-provided by `display-buffer-alist'.  If the value of the latter
-is nil too, all specifiers are provided by the constant
-`display-buffer-default-specifiers'.
+provided by the variable `display-buffer-alist' and the function
+`display-buffer-normalize-default'.
 
 As a special case, the `reuse-window' specifier allows to specify
 as second element an arbitrary window, as third element an
@@ -5707,7 +5701,7 @@
         ;; Don't use a minibuffer frame.
         (frame (display-buffer-frame))
         ;; `window' is the window we use for showing `buffer'.
-        window specifier method)
+        window specifier method other-window)
     ;; Reset this.
     (setq display-buffer-window nil)
     (if display-buffer-function
@@ -5723,7 +5717,7 @@
              (cond
               ((eq method 'reuse-window)
                (display-buffer-reuse-window
-                buffer (cdr specifier) normalized))
+                buffer (cdr specifier) normalized other-window))
               ((eq method 'pop-up-window)
                (display-buffer-pop-up-window
                 buffer (cdr specifier) normalized))
@@ -5734,25 +5728,31 @@
                (display-buffer-in-side-window
                 buffer (nth 1 specifier) (nth 2 specifier) normalized))
               ((eq method 'function)
-               (funcall (nth 1 specifier) buffer (nth 2 specifier))))))
+               (funcall (nth 1 specifier) buffer (nth 2 specifier)))
+              ((eq method 'other-window)
+               (setq other-window t)))))
 
       ;; If we don't have a window yet, try a fallback method.  All
-      ;; specifiers have been used up by now.
+      ;; specifiers have been used up by now.  Try reusing a window
       (or (and (window-live-p window) window)
-         ;; Try reusing a window showing BUFFER on any visible or
-         ;; iconfied frame.
-         (display-buffer-reuse-window buffer `(nil ,buffer 0))
-         ;; Try reusing a window not showing BUFFER on any visible or
-         ;; iconified frame.
-         (display-buffer-reuse-window buffer '(nil other 0))
-         ;; Eli says it's better to never try making a new frame.
-         ;; (display-buffer-pop-up-frame buffer)
-         ;; Try using a weakly dedicated window.
-         (display-buffer-reuse-window
-          buffer '(nil nil t) '((reuse-window-dedicated . weak)))
-         ;; Try using a strongly dedicated window.
-         (display-buffer-reuse-window
-          buffer '(nil nil t) '((reuse-window-dedicated . t)))))))
+         ;; on the selected frame,
+         (display-buffer-reuse-window
+          buffer '(nil nil nil) other-window)
+         ;; showing BUFFER on any visible frame,
+         (display-buffer-reuse-window
+          buffer '(nil same visible) other-window)
+         ;; not showing BUFFER on any visible frame,
+         (display-buffer-reuse-window
+          buffer '(nil other visible) other-window)
+         ;; showing BUFFER on any visible or iconified frame,
+         (display-buffer-reuse-window
+          buffer '(nil same 0) other-window)
+         ;; not showing BUFFER on any visible or iconified frame.
+         (display-buffer-reuse-window
+          buffer '(nil other 0) other-window)
+         ;; If everything failed so far, try popping up a new frame
+         ;; regardless of graphic-only restrictions.
+         (display-buffer-pop-up-frame buffer)))))
 
 (defsubst display-buffer-same-window (&optional buffer-or-name label)
   "Display buffer specified by BUFFER-OR-NAME in the selected window.
@@ -6395,10 +6395,9 @@
  ;; 'display-buffer-reuse-frames
  ;; "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."
+(defcustom pop-up-windows t
+  "Non-nil means `display-buffer' should make a new window."
   :type 'boolean
-  :version "24.1"
   :group 'windows)
 ;; (make-obsolete-variable
  ;; 'pop-up-windows
@@ -6459,13 +6458,12 @@
  ;; 'split-width-threshold
  ;; "use 2nd arg of `display-buffer' instead." "24.1")
 
-(defcustom even-window-heights 'unset ; t
-  "If set and non-nil `display-buffer' will try to even window heights.
+(defcustom even-window-heights t
+  "If 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
+alone.  Heights are evened only when `display-buffer' chooses a
 window that appears above or below the selected window."
   :type 'boolean
-  :version "24.1"
   :group 'windows)
 ;; (make-obsolete-variable
  ;; 'even-window-heights
@@ -6635,7 +6633,7 @@
              1.0)))
        (list
        'pop-up-window
-       (when pop-up-windows ; unset qualifies as t
+       (when pop-up-windows
          (list
           'pop-up-window
           (cons 'largest fun)
@@ -6789,7 +6787,7 @@
              ;; "0" (all visible and iconified frames) is hardcoded in
              ;; Emacs 23.
              0))
-      (unless (memq even-window-heights '(nil unset))
+      (when even-window-heights
        (cons 'reuse-window-even-sizes t)))
      no-custom)
 
@@ -6798,7 +6796,7 @@
       (display-buffer-alist-add
        nil
        (list
-       (cons 'dedicated display-buffer-mark-dedicated))
+       (cons 'dedicate display-buffer-mark-dedicated))
        no-custom)))
 
   display-buffer-alist)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]