Mercurial > emacs
comparison lisp/frame.el @ 101168:f6eac5742ca0
(special-display-popup-frame): Rewrite doc-string and simplify code.
author | Martin Rudalics <rudalics@gmx.at> |
---|---|
date | Wed, 14 Jan 2009 10:12:01 +0000 |
parents | e75e790488a6 |
children | 191a3121c949 |
comparison
equal
deleted
inserted
replaced
101167:a4d9fa835dc5 | 101168:f6eac5742ca0 |
---|---|
103 | 103 |
104 If non-nil, the value you specify here is used by the default | 104 If non-nil, the value you specify here is used by the default |
105 `pop-up-frame-function' for the creation of new frames. | 105 `pop-up-frame-function' for the creation of new frames. |
106 | 106 |
107 Since `pop-up-frame-function' is used by `display-buffer' for | 107 Since `pop-up-frame-function' is used by `display-buffer' for |
108 making new frames, any value specified here, by default affects | 108 making new frames, any value specified here by default affects |
109 the automatic generation of new frames via `display-buffer' and | 109 the automatic generation of new frames via `display-buffer' and |
110 all functions based on it. The behavior of `make-frame' is not | 110 all functions based on it. The behavior of `make-frame' is not |
111 affected by this variable." | 111 affected by this variable." |
112 :type '(repeat (cons :format "%v" | 112 :type '(repeat (cons :format "%v" |
113 (symbol :tag "Parameter") | 113 (symbol :tag "Parameter") |
124 :group 'frames) | 124 :group 'frames) |
125 | 125 |
126 (defcustom special-display-frame-alist | 126 (defcustom special-display-frame-alist |
127 '((height . 14) (width . 80) (unsplittable . t)) | 127 '((height . 14) (width . 80) (unsplittable . t)) |
128 "Alist of parameters for special frames. | 128 "Alist of parameters for special frames. |
129 Special frames are used for buffers whose names are in | 129 Special frames are used for buffers whose names are listed in |
130 `special-display-buffer-names' and for buffers whose names match | 130 `special-display-buffer-names' and for buffers whose names match |
131 one of the regular expressions in `special-display-regexps'. | 131 one of the regular expressions in `special-display-regexps'. |
132 | 132 |
133 This variable can be set in your init file, like this: | 133 This variable can be set in your init file, like this: |
134 | 134 |
139 (symbol :tag "Parameter") | 139 (symbol :tag "Parameter") |
140 (sexp :tag "Value"))) | 140 (sexp :tag "Value"))) |
141 :group 'frames) | 141 :group 'frames) |
142 | 142 |
143 (defun special-display-popup-frame (buffer &optional args) | 143 (defun special-display-popup-frame (buffer &optional args) |
144 "Display BUFFER in its own frame, reusing an existing window if any. | 144 "Display BUFFER and return the window chosen. |
145 Return the window chosen. | 145 If BUFFER is already displayed in a visible or iconified frame, |
146 Currently we do not insist on selecting the window within its frame. | 146 raise that frame. Otherwise, display BUFFER in a new frame. |
147 If ARGS is an alist, use it as a list of frame parameter specs. | 147 |
148 If ARGS is a list whose car is a symbol, | 148 Optional argument ARGS is a list specifying additional |
149 use (car ARGS) as a function to do the work. | 149 information. |
150 Pass it BUFFER as first arg, and (cdr ARGS) gives the rest of the args." | 150 |
151 If ARGS is an alist, use it as a list of frame parameters. If | |
152 these parameters contain \(same-window . t), display BUFFER in | |
153 the selected window. If they contain \(same-frame . t), display | |
154 BUFFER in a window of the selected frame. | |
155 | |
156 If ARGS is a list whose car is a symbol, use (car ARGS) as a | |
157 function to do the work. Pass it BUFFER as first argument, | |
158 and (cdr ARGS) as second." | |
151 (if (and args (symbolp (car args))) | 159 (if (and args (symbolp (car args))) |
152 (apply (car args) buffer (cdr args)) | 160 (apply (car args) buffer (cdr args)) |
153 (let ((window (get-buffer-window buffer 0))) | 161 (let ((window (get-buffer-window buffer 0))) |
154 (or | 162 (or |
155 ;; If we have a window already, make it visible. | 163 ;; If we have a window already, make it visible. |
163 (condition-case nil | 171 (condition-case nil |
164 (progn (switch-to-buffer buffer) (selected-window)) | 172 (progn (switch-to-buffer buffer) (selected-window)) |
165 (error nil))) | 173 (error nil))) |
166 ;; Stay on the same frame if requested. | 174 ;; Stay on the same frame if requested. |
167 (when (or (cdr (assq 'same-frame args)) (cdr (assq 'same-window args))) | 175 (when (or (cdr (assq 'same-frame args)) (cdr (assq 'same-window args))) |
168 (let* ((pop-up-frames nil) (pop-up-windows t) | 176 (let* ((pop-up-windows t) |
169 special-display-regexps special-display-buffer-names | 177 pop-up-frames |
170 (window (display-buffer buffer))) | 178 special-display-buffer-names special-display-regexps) |
171 ;; Only do it if this is a new window: | 179 (display-buffer buffer))) |
172 ;; (set-window-dedicated-p window t) | |
173 window)) | |
174 ;; If no window yet, make one in a new frame. | 180 ;; If no window yet, make one in a new frame. |
175 (let ((frame | 181 (let ((frame |
176 (with-current-buffer buffer | 182 (with-current-buffer buffer |
177 (make-frame (append args special-display-frame-alist))))) | 183 (make-frame (append args special-display-frame-alist))))) |
178 (set-window-buffer (frame-selected-window frame) buffer) | 184 (set-window-buffer (frame-selected-window frame) buffer) |