diff options
Diffstat (limited to 'lisp/window.el')
| -rw-r--r-- | lisp/window.el | 56 |
1 files changed, 31 insertions, 25 deletions
diff --git a/lisp/window.el b/lisp/window.el index 2885c3a5c70..69276a839bd 100644 --- a/lisp/window.el +++ b/lisp/window.el | |||
| @@ -170,7 +170,7 @@ Applications should never rebind this variable. To resize a | |||
| 170 | window to a height less than the one specified here, an | 170 | window to a height less than the one specified here, an |
| 171 | application should instead call `window-resize' with a non-nil | 171 | application should instead call `window-resize' with a non-nil |
| 172 | IGNORE argument. In order to have `split-window' make a window | 172 | IGNORE argument. In order to have `split-window' make a window |
| 173 | shorter, explictly specify the SIZE argument of that function." | 173 | shorter, explicitly specify the SIZE argument of that function." |
| 174 | :type 'integer | 174 | :type 'integer |
| 175 | :version "24.1" | 175 | :version "24.1" |
| 176 | :group 'windows) | 176 | :group 'windows) |
| @@ -190,7 +190,7 @@ Applications should never rebind this variable. To resize a | |||
| 190 | window to a width less than the one specified here, an | 190 | window to a width less than the one specified here, an |
| 191 | application should instead call `window-resize' with a non-nil | 191 | application should instead call `window-resize' with a non-nil |
| 192 | IGNORE argument. In order to have `split-window' make a window | 192 | IGNORE argument. In order to have `split-window' make a window |
| 193 | narrower, explictly specify the SIZE argument of that function." | 193 | narrower, explicitly specify the SIZE argument of that function." |
| 194 | :type 'integer | 194 | :type 'integer |
| 195 | :version "24.1" | 195 | :version "24.1" |
| 196 | :group 'windows) | 196 | :group 'windows) |
| @@ -4515,6 +4515,12 @@ Return WINDOW." | |||
| 4515 | (set-window-dedicated-p window dedicated)) | 4515 | (set-window-dedicated-p window dedicated)) |
| 4516 | (window--display-buffer-1 window))) | 4516 | (window--display-buffer-1 window))) |
| 4517 | 4517 | ||
| 4518 | ;; FIXME: Not implemented. | ||
| 4519 | ;; FIXME: By the way, there could be more levels of dedication: | ||
| 4520 | ;; - `barely' dedicated doesn't prevent reuse of the window, only records that | ||
| 4521 | ;; the window hasn't been used for something else yet. | ||
| 4522 | ;; - `softly' dedicated only allows reuse when asked explicitly. | ||
| 4523 | ;; - `strongly' never allows reuse. | ||
| 4518 | (defvar display-buffer-mark-dedicated nil | 4524 | (defvar display-buffer-mark-dedicated nil |
| 4519 | "If non-nil, `display-buffer' marks the windows it creates as dedicated. | 4525 | "If non-nil, `display-buffer' marks the windows it creates as dedicated. |
| 4520 | The actual non-nil value of this variable will be copied to the | 4526 | The actual non-nil value of this variable will be copied to the |
| @@ -4522,7 +4528,7 @@ The actual non-nil value of this variable will be copied to the | |||
| 4522 | 4528 | ||
| 4523 | (defun window-normalize-buffer-to-display (buffer-or-name) | 4529 | (defun window-normalize-buffer-to-display (buffer-or-name) |
| 4524 | "Normalize BUFFER-OR-NAME argument for buffer display functions. | 4530 | "Normalize BUFFER-OR-NAME argument for buffer display functions. |
| 4525 | If BUFFER-OR-NAME is nil, return the curent buffer. Else, if a | 4531 | If BUFFER-OR-NAME is nil, return the current buffer. Else, if a |
| 4526 | buffer specified by BUFFER-OR-NAME exists, return that buffer. | 4532 | buffer specified by BUFFER-OR-NAME exists, return that buffer. |
| 4527 | If no such buffer exists, create a buffer with the name | 4533 | If no such buffer exists, create a buffer with the name |
| 4528 | BUFFER-OR-NAME and return that buffer." | 4534 | BUFFER-OR-NAME and return that buffer." |
| @@ -4786,9 +4792,10 @@ terminal if either of those variables is non-nil." | |||
| 4786 | (window--display-buffer-1 window)))) | 4792 | (window--display-buffer-1 window)))) |
| 4787 | 4793 | ||
| 4788 | (defun display-buffer--special-action (buffer) | 4794 | (defun display-buffer--special-action (buffer) |
| 4789 | "Try to display BUFFER using `special-display-function'. | 4795 | "Return special display action for BUFFER, if any. |
| 4790 | Call `special-display-p' on BUFFER's name, and if that returns | 4796 | If `special-display-p' returns non-nil for BUFFER, return an |
| 4791 | non-nil, call `special-display-function' on BUFFER." | 4797 | appropriate display action involving `special-display-function'. |
| 4798 | See `display-buffer' for the format of display actions." | ||
| 4792 | (and special-display-function | 4799 | (and special-display-function |
| 4793 | ;; `special-display-p' returns either t or a list of frame | 4800 | ;; `special-display-p' returns either t or a list of frame |
| 4794 | ;; parameters to pass to `special-display-function'. | 4801 | ;; parameters to pass to `special-display-function'. |
| @@ -4944,10 +4951,7 @@ the buffer. | |||
| 4944 | 4951 | ||
| 4945 | NORECORD, if non-nil means do not put this buffer at the front of | 4952 | NORECORD, if non-nil means do not put this buffer at the front of |
| 4946 | the list of recently selected ones." | 4953 | the list of recently selected ones." |
| 4947 | (pop-to-buffer buffer | 4954 | (pop-to-buffer buffer display-buffer--same-window-action norecord)) |
| 4948 | '(display-buffer-same-window | ||
| 4949 | (inhibit-same-window . nil)) | ||
| 4950 | norecord)) | ||
| 4951 | 4955 | ||
| 4952 | (defun read-buffer-to-switch (prompt) | 4956 | (defun read-buffer-to-switch (prompt) |
| 4953 | "Read the name of a buffer to switch to, prompting with PROMPT. | 4957 | "Read the name of a buffer to switch to, prompting with PROMPT. |
| @@ -5012,21 +5016,23 @@ Return the buffer switched to." | |||
| 5012 | (interactive | 5016 | (interactive |
| 5013 | (list (read-buffer-to-switch "Switch to buffer: ") nil 'force-same-window)) | 5017 | (list (read-buffer-to-switch "Switch to buffer: ") nil 'force-same-window)) |
| 5014 | (let ((buffer (window-normalize-buffer-to-switch-to buffer-or-name))) | 5018 | (let ((buffer (window-normalize-buffer-to-switch-to buffer-or-name))) |
| 5015 | (if (null force-same-window) | 5019 | (cond |
| 5016 | (pop-to-buffer buffer display-buffer--same-window-action norecord) | 5020 | ;; Don't call set-window-buffer if it's not needed since it |
| 5017 | (cond | 5021 | ;; might signal an error (e.g. if the window is dedicated). |
| 5018 | ;; Don't call set-window-buffer if it's not needed since it | 5022 | ((eq buffer (window-buffer))) |
| 5019 | ;; might signal an error (e.g. if the window is dedicated). | 5023 | ((window-minibuffer-p) |
| 5020 | ((eq buffer (window-buffer))) | 5024 | (if force-same-window |
| 5021 | ((window-minibuffer-p) | 5025 | (error "Cannot switch buffers in minibuffer window") |
| 5022 | (error "Cannot switch buffers in minibuffer window")) | 5026 | (pop-to-buffer buffer norecord))) |
| 5023 | ((eq (window-dedicated-p) t) | 5027 | ((eq (window-dedicated-p) t) |
| 5024 | (error "Cannot switch buffers in a dedicated window")) | 5028 | (if force-same-window |
| 5025 | (t (set-window-buffer nil buffer))) | 5029 | (error "Cannot switch buffers in a dedicated window") |
| 5026 | 5030 | (pop-to-buffer buffer norecord))) | |
| 5027 | (unless norecord | 5031 | (t (set-window-buffer nil buffer))) |
| 5028 | (select-window (selected-window))) | 5032 | |
| 5029 | (set-buffer buffer)))) | 5033 | (unless norecord |
| 5034 | (select-window (selected-window))) | ||
| 5035 | (set-buffer buffer))) | ||
| 5030 | 5036 | ||
| 5031 | (defun switch-to-buffer-other-window (buffer-or-name &optional norecord) | 5037 | (defun switch-to-buffer-other-window (buffer-or-name &optional norecord) |
| 5032 | "Select the buffer specified by BUFFER-OR-NAME in another window. | 5038 | "Select the buffer specified by BUFFER-OR-NAME in another window. |