aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Rudalics2011-06-17 16:50:11 +0200
committerMartin Rudalics2011-06-17 16:50:11 +0200
commit25aef8b85bc4eb4b83fc5b62bab6f95f43447394 (patch)
tree0450497a9c384b2f61f9138b597b56bf2b2d7ab6
parentce4331ef48cff5ea38895a6b153967d54799cd47 (diff)
downloademacs-25aef8b85bc4eb4b83fc5b62bab6f95f43447394.tar.gz
emacs-25aef8b85bc4eb4b83fc5b62bab6f95f43447394.zip
Rewrite display-buffer-alist and display-buffer-normalize-specifiers.
* window.el (display-buffer-alist): Set pop-up-window-min-height and pop-up-window-min-width in default value. Reported by Thierry Volpiatto <thierry.volpiatto@gmail.com>. New specifier other-window-means-other-frame. (display-buffer-macro-specifiers): Comment out entry for other-window specifier. (display-buffer-other-window-means-other-frame): New function. (display-buffer-normalize-specifiers-1): New arguments buffer-name and label. Treat other-window case specially. (display-buffer-normalize-specifiers-2): Treat other-window case specially. (display-buffer-normalize-specifiers-3): New function. (display-buffer-normalize-specifiers): Call display-buffer-normalize-specifiers-3.
-rw-r--r--lisp/ChangeLog19
-rw-r--r--lisp/window.el131
2 files changed, 109 insertions, 41 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index b55f15a389d..617120a5a11 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,22 @@
12011-06-17 Martin Rudalics <rudalics@gmx.at> 12011-06-17 Martin Rudalics <rudalics@gmx.at>
2 2
3 * window.el (display-buffer-alist): Set pop-up-window-min-height
4 and pop-up-window-min-width in default value. Reported by
5 Thierry Volpiatto <thierry.volpiatto@gmail.com>. New specifier
6 other-window-means-other-frame.
7 (display-buffer-macro-specifiers): Comment out entry for
8 other-window specifier.
9 (display-buffer-other-window-means-other-frame): New function.
10 (display-buffer-normalize-specifiers-1): New arguments
11 buffer-name and label. Treat other-window case specially.
12 (display-buffer-normalize-specifiers-2): Treat other-window case
13 specially.
14 (display-buffer-normalize-specifiers-3): New function.
15 (display-buffer-normalize-specifiers): Call
16 display-buffer-normalize-specifiers-3.
17
182011-06-17 Martin Rudalics <rudalics@gmx.at>
19
3 * window.el (same-window-p): Fix two typos introduced when 20 * window.el (same-window-p): Fix two typos introduced when
4 adding with-no-warnings. 21 adding with-no-warnings.
5 (display-buffer-normalize-specifiers-1): Don't check 22 (display-buffer-normalize-specifiers-1): Don't check
@@ -11,6 +28,8 @@
11 Suggested by David Engster <deng@randomsample.de>. 28 Suggested by David Engster <deng@randomsample.de>.
12 (even-window-heights): Initialize to 'unset. 29 (even-window-heights): Initialize to 'unset.
13 (display-buffer-alist-set): Handle new 'unset initializations. 30 (display-buffer-alist-set): Handle new 'unset initializations.
31 (display-buffer-macro-specifiers): Don't pop up a new frame in the
32 other window case.
14 33
152011-06-16 Martin Rudalics <rudalics@gmx.at> 342011-06-16 Martin Rudalics <rudalics@gmx.at>
16 35
diff --git a/lisp/window.el b/lisp/window.el
index 07835e29b0d..2c38212de58 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -3500,12 +3500,11 @@ buffer display specifiers.")
3500 (reuse-window nil same nil) 3500 (reuse-window nil same nil)
3501 (pop-up-window (largest . nil) (lru . nil)) 3501 (pop-up-window (largest . nil) (lru . nil))
3502 (reuse-window nil other nil)) 3502 (reuse-window nil other nil))
3503 (other-window 3503 ;; (other-window
3504 ;; Avoid selected window. 3504 ;; ;; Avoid selected window.
3505 (reuse-window other same visible) 3505 ;; (reuse-window other same visible)
3506 (pop-up-window (largest . nil) (lru . nil)) 3506 ;; (pop-up-window (largest . nil) (lru . nil))
3507 (pop-up-frame) 3507 ;; (reuse-window other other visible))
3508 (reuse-window other other visible))
3509 (same-frame-other-window 3508 (same-frame-other-window
3510 ;; Avoid other frames and selected window. 3509 ;; Avoid other frames and selected window.
3511 (reuse-window other same nil) 3510 (reuse-window other same nil)
@@ -3523,10 +3522,16 @@ buffer display specifiers.")
3523 3522
3524(defcustom display-buffer-alist 3523(defcustom display-buffer-alist
3525 '((((regexp . ".*")) 3524 '((((regexp . ".*"))
3525 ;; Reuse window showing same buffer.
3526 reuse-window (reuse-window nil same visible) 3526 reuse-window (reuse-window nil same visible)
3527 ;; Pop up window.
3527 pop-up-window 3528 pop-up-window
3529 ;; Split largest or lru window.
3528 (pop-up-window (largest . nil) (lru . nil)) 3530 (pop-up-window (largest . nil) (lru . nil))
3529 reuse-window (reuse-window other other nil) 3531 (pop-up-window-min-height . 40) ; split-height-threshold / 2
3532 (pop-up-window-min-width . 80) ; split-width-threshold / 2
3533 ;; Reuse any but selected window on same frame.
3534 reuse-window (reuse-window other nil nil)
3530 (reuse-window-even-sizes . t))) 3535 (reuse-window-even-sizes . t)))
3531 "List associating buffer identifiers with display specifiers. 3536 "List associating buffer identifiers with display specifiers.
3532The car of each element of this list is built from a set of cons 3537The car of each element of this list is built from a set of cons
@@ -4231,6 +4236,15 @@ using the location specifiers `same-window' or `other-frame'."
4231 :format "%[No other window%] %v\n" :size 15 4236 :format "%[No other window%] %v\n" :size 15
4232 (const :tag "Off" :format "%t" nil) 4237 (const :tag "Off" :format "%t" nil)
4233 (const :tag "Ignore" :format "%t" t))) 4238 (const :tag "Ignore" :format "%t" t)))
4239 ;; Other window means other frame.
4240 (cons
4241 :format "%v"
4242 (const :format "" other-window-means-other-frame)
4243 (choice
4244 :help-echo "Whether other window means same or other frame."
4245 :format "%[Same or other frame%] %v\n" :size 15
4246 (const :tag "Same frame" :format "%t" nil)
4247 (const :tag "Other frame" :format "%t" t)))
4234 ;; Overriding. 4248 ;; Overriding.
4235 (cons 4249 (cons
4236 :format "%v\n" 4250 :format "%v\n"
@@ -4915,6 +4929,26 @@ SPECIFIERS must be a list of buffer display specifiers."
4915 (set-window-parameter window 'window-slot slot)) 4929 (set-window-parameter window 'window-slot slot))
4916 (display-buffer-in-window buffer window specifiers))))) 4930 (display-buffer-in-window buffer window specifiers)))))
4917 4931
4932(defun display-buffer-other-window-means-other-frame (buffer-or-name &optional label)
4933 "Return non-nil if BUFFER shall be preferably displayed in another frame.
4934BUFFER must be a live buffer or the name of a live buffer.
4935
4936Return nil if BUFFER shall be preferably displayed in another
4937window on the selected frame. Return non-nil if BUFFER shall be
4938preferably displayed in a window on any but the selected frame.
4939
4940Optional argument LABEL is like the same argument of
4941`display-buffer'.
4942
4943The calculation of the return value is exclusively based on the
4944user preferences expressed in `display-buffer-alist'."
4945 (let* ((buffer (normalize-live-buffer buffer-or-name))
4946 (list (display-buffer-normalize-specifiers-3
4947 (buffer-name buffer) label))
4948 (value (assq 'other-window-means-other-frame
4949 (or (car list) (cdr list)))))
4950 (when value (cdr value))))
4951
4918(defun normalize-buffer-to-display (buffer-or-name) 4952(defun normalize-buffer-to-display (buffer-or-name)
4919 "Normalize BUFFER-OR-NAME argument for buffer display functions. 4953 "Normalize BUFFER-OR-NAME argument for buffer display functions.
4920If BUFFER-OR-NAME is nil, return the curent buffer. Else, if a 4954If BUFFER-OR-NAME is nil, return the curent buffer. Else, if a
@@ -4928,9 +4962,11 @@ BUFFER-OR-NAME and return that buffer."
4928 buffer)) 4962 buffer))
4929 (current-buffer))) 4963 (current-buffer)))
4930 4964
4931(defun display-buffer-normalize-specifiers-1 (specifiers) 4965(defun display-buffer-normalize-specifiers-1 (specifiers buffer-name label)
4932 "Subroutine of `display-buffer-normalize-specifiers'. 4966 "Subroutine of `display-buffer-normalize-specifiers'.
4933SPECIFIERS is the SPECIFIERS argument of `display-buffer'." 4967SPECIFIERS is a list of buffer display specfiers. BUFFER-NAME is
4968the name of the buffer that shall be displayed, LABEL the same
4969argument of `display-buffer'."
4934 (let (normalized entry) 4970 (let (normalized entry)
4935 (cond 4971 (cond
4936 ((not specifiers) 4972 ((not specifiers)
@@ -4941,6 +4977,14 @@ SPECIFIERS is the SPECIFIERS argument of `display-buffer'."
4941 (cond 4977 (cond
4942 ((consp specifier) 4978 ((consp specifier)
4943 (setq normalized (cons specifier normalized))) 4979 (setq normalized (cons specifier normalized)))
4980 ((eq specifier 'other-window)
4981 ;; `other-window' must be treated separately.
4982 (let* ((other-frame (display-buffer-other-window-means-other-frame
4983 buffer-name label))
4984 (entry (assq (if other-frame 'other-frame 'other-window)
4985 display-buffer-macro-specifiers)))
4986 (dolist (item (cdr entry))
4987 (setq normalized (cons item normalized)))))
4944 ((symbolp specifier) 4988 ((symbolp specifier)
4945 ;; Might be a macro specifier, try to expand it (the cdr is a 4989 ;; Might be a macro specifier, try to expand it (the cdr is a
4946 ;; list and we have to reverse it later, so do it one at a 4990 ;; list and we have to reverse it later, so do it one at a
@@ -4950,16 +4994,15 @@ SPECIFIERS is the SPECIFIERS argument of `display-buffer'."
4950 (setq normalized (cons item normalized))))))) 4994 (setq normalized (cons item normalized)))))))
4951 ;; Reverse list. 4995 ;; Reverse list.
4952 (nreverse normalized)) 4996 (nreverse normalized))
4953 ((and (not (eq specifiers 'other-window)) 4997 ((setq entry (assq specifiers display-buffer-macro-specifiers))
4954 (setq entry (assq specifiers display-buffer-macro-specifiers)))
4955 ;; A macro specifier. 4998 ;; A macro specifier.
4956 (cdr entry)) 4999 (cdr entry))
4957 ((with-no-warnings (not pop-up-frames)) 5000 ((or (display-buffer-other-window-means-other-frame buffer-name label)
4958 ;; Pop up a new window. 5001 (with-no-warnings (not pop-up-frames)))
4959 (cdr (assq 'other-window display-buffer-macro-specifiers))) 5002 (cdr (assq 'other-frame display-buffer-macro-specifiers)))
4960 (t 5003 (t
4961 ;; Pop up a new frame. 5004 ;; In any other case pop up a new window.
4962 (cdr (assq 'other-frame display-buffer-macro-specifiers)))))) 5005 (cdr (assq 'same-frame-other-window display-buffer-macro-specifiers))))))
4963 5006
4964(defun display-buffer-normalize-specifiers-2 (&optional buffer-or-name) 5007(defun display-buffer-normalize-specifiers-2 (&optional buffer-or-name)
4965 "Subroutine of `display-buffer-normalize-specifiers'. 5008 "Subroutine of `display-buffer-normalize-specifiers'.
@@ -5064,27 +5107,8 @@ options."
5064 5107
5065 specifiers))) 5108 specifiers)))
5066 5109
5067(defun display-buffer-normalize-specifiers (buffer-name specifiers label) 5110(defun display-buffer-normalize-specifiers-3 (buffer-name label)
5068 "Return normalized specifiers for a buffer matching BUFFER-NAME or LABEL. 5111 "Subroutine of `display-buffer-normalize-specifiers'."
5069BUFFER-NAME must be a string specifying a valid buffer name.
5070SPECIFIERS and LABEL are the homonymous arguments of
5071`display-buffer'.
5072
5073The method for displaying the buffer specified by BUFFER-NAME or
5074LABEL is established by appending the following four lists of
5075specifiers:
5076
5077- The specifiers in `display-buffer-alist' whose buffer
5078 identifier matches BUFFER-NAME or LABEL and whose 'override
5079 component is set.
5080
5081- SPECIFIERS.
5082
5083- The specifiers in `display-buffer-alist' whose buffer
5084 identifier matches BUFFER-NAME or LABEL and whose 'override
5085 component is not set.
5086
5087- `display-buffer-default-specifiers'."
5088 (let (list-1 list-2) 5112 (let (list-1 list-2)
5089 (dolist (entry display-buffer-alist) 5113 (dolist (entry display-buffer-alist)
5090 (when (and (listp entry) 5114 (when (and (listp entry)
@@ -5100,7 +5124,8 @@ specifiers:
5100 (and (eq type 'label) (eq value label))) 5124 (and (eq type 'label) (eq value label)))
5101 (throw 'match t))))))) 5125 (throw 'match t)))))))
5102 (let* ((raw (cdr entry)) 5126 (let* ((raw (cdr entry))
5103 (normalized (display-buffer-normalize-specifiers-1 raw))) 5127 (normalized
5128 (display-buffer-normalize-specifiers-1 raw buffer-name label)))
5104 (if (assq 'override raw) 5129 (if (assq 'override raw)
5105 (setq list-1 5130 (setq list-1
5106 (if list-1 5131 (if list-1
@@ -5111,15 +5136,39 @@ specifiers:
5111 (append list-2 normalized) 5136 (append list-2 normalized)
5112 normalized)))))) 5137 normalized))))))
5113 5138
5139 (cons list-1 list-2)))
5140
5141(defun display-buffer-normalize-specifiers (buffer-name specifiers label)
5142 "Return normalized specifiers for a buffer matching BUFFER-NAME or LABEL.
5143BUFFER-NAME must be a string specifying a valid buffer name.
5144SPECIFIERS and LABEL are the homonymous arguments of
5145`display-buffer'.
5146
5147The method for displaying the buffer specified by BUFFER-NAME or
5148LABEL is established by appending the following four lists of
5149specifiers:
5150
5151- The specifiers in `display-buffer-alist' whose buffer
5152 identifier matches BUFFER-NAME or LABEL and whose 'override
5153 component is set.
5154
5155- SPECIFIERS.
5156
5157- The specifiers in `display-buffer-alist' whose buffer
5158 identifier matches BUFFER-NAME or LABEL and whose 'override
5159 component is not set.
5160
5161- `display-buffer-default-specifiers'."
5162 (let* ((list (display-buffer-normalize-specifiers-3 buffer-name label)))
5114 (append 5163 (append
5115 ;; Overriding user specifiers. 5164 ;; Overriding user specifiers.
5116 list-1 5165 (car list)
5117 ;; Application specifiers. 5166 ;; Application specifiers.
5118 (display-buffer-normalize-specifiers-1 specifiers) 5167 (display-buffer-normalize-specifiers-1 specifiers buffer-name label)
5119 ;; Emacs 23 compatibility specifiers. 5168 ;; Emacs 23 compatibility specifiers.
5120 (display-buffer-normalize-specifiers-2 buffer-name) 5169 (display-buffer-normalize-specifiers-2 buffer-name)
5121 ;; Non-overriding user specifiers. 5170 ;; Non-overriding user specifiers.
5122 list-2 5171 (cdr list)
5123 ;; Default specifiers. 5172 ;; Default specifiers.
5124 display-buffer-default-specifiers))) 5173 display-buffer-default-specifiers)))
5125 5174