diff options
| -rw-r--r-- | lisp/window.el | 46 |
1 files changed, 31 insertions, 15 deletions
diff --git a/lisp/window.el b/lisp/window.el index 5ba9a305f96..c0a9ecd093c 100644 --- a/lisp/window.el +++ b/lisp/window.el | |||
| @@ -320,22 +320,34 @@ WINDOW can be any window." | |||
| 320 | 320 | ||
| 321 | (defun window-normalize-buffer (buffer-or-name) | 321 | (defun window-normalize-buffer (buffer-or-name) |
| 322 | "Return buffer specified by BUFFER-OR-NAME. | 322 | "Return buffer specified by BUFFER-OR-NAME. |
| 323 | BUFFER-OR-NAME must be either a buffer or a string naming a live | 323 | BUFFER-OR-NAME must be a live buffer, a string naming a live |
| 324 | buffer and defaults to the current buffer." | 324 | buffer or nil which means to return the current buffer. |
| 325 | (cond | 325 | |
| 326 | ((not buffer-or-name) | 326 | This function is commonly used to process the (usually optional) |
| 327 | (current-buffer)) | 327 | \"BUFFER-OR-NAME\" argument of window related functions where nil |
| 328 | ((bufferp buffer-or-name) | 328 | stands for the current buffer." |
| 329 | (if (buffer-live-p buffer-or-name) | 329 | (let ((buffer |
| 330 | buffer-or-name | 330 | (cond |
| 331 | (error "Buffer %s is not a live buffer" buffer-or-name))) | 331 | ((not buffer-or-name) |
| 332 | ((get-buffer buffer-or-name)) | 332 | (current-buffer)) |
| 333 | (t | 333 | ((bufferp buffer-or-name) |
| 334 | (error "No such buffer %s" buffer-or-name)))) | 334 | buffer-or-name) |
| 335 | ((stringp buffer-or-name) | ||
| 336 | (get-buffer buffer-or-name)) | ||
| 337 | (t | ||
| 338 | (error "No such buffer %s" buffer-or-name))))) | ||
| 339 | (if (buffer-live-p buffer) | ||
| 340 | buffer | ||
| 341 | (error "No such live buffer %s" buffer-or-name)))) | ||
| 335 | 342 | ||
| 336 | (defun window-normalize-frame (frame) | 343 | (defun window-normalize-frame (frame) |
| 337 | "Return frame specified by FRAME. | 344 | "Return frame specified by FRAME. |
| 338 | FRAME must be a live frame and defaults to the selected frame." | 345 | FRAME must be a live frame or nil which means to return the |
| 346 | selected frame. | ||
| 347 | |||
| 348 | This function is commonly used to process the (usually optional) | ||
| 349 | \"FRAME\" argument of window and frame related functions where | ||
| 350 | nil stands for the selected frame." | ||
| 339 | (if frame | 351 | (if frame |
| 340 | (if (frame-live-p frame) | 352 | (if (frame-live-p frame) |
| 341 | frame | 353 | frame |
| @@ -343,11 +355,15 @@ FRAME must be a live frame and defaults to the selected frame." | |||
| 343 | (selected-frame))) | 355 | (selected-frame))) |
| 344 | 356 | ||
| 345 | (defun window-normalize-window (window &optional live-only) | 357 | (defun window-normalize-window (window &optional live-only) |
| 346 | "Return the window specified by WINDOW. | 358 | "Return window specified by WINDOW. |
| 347 | If WINDOW is nil, return the selected window. Otherwise, if | 359 | If WINDOW is nil, return the selected window. Otherwise, if |
| 348 | WINDOW is a live or an internal window, return WINDOW; if | 360 | WINDOW is a live or an internal window, return WINDOW; if |
| 349 | LIVE-ONLY is non-nil, return WINDOW for a live window only. | 361 | LIVE-ONLY is non-nil, return WINDOW for a live window only. |
| 350 | Otherwise, signal an error." | 362 | Otherwise, signal an error. |
| 363 | |||
| 364 | This function is commonly used to process the (usually optional) | ||
| 365 | \"WINDOW\" argument of window related functions where nil stands | ||
| 366 | for the selected window." | ||
| 351 | (cond | 367 | (cond |
| 352 | ((null window) | 368 | ((null window) |
| 353 | (selected-window)) | 369 | (selected-window)) |