diff options
| author | Stefan Monnier | 2011-11-28 14:43:52 -0500 |
|---|---|---|
| committer | Stefan Monnier | 2011-11-28 14:43:52 -0500 |
| commit | 24510c22a36564fe6c4b6f79a30fc41fee89b45b (patch) | |
| tree | 919d35c8e3c5d39e485995b65ae01e6d711579cf | |
| parent | c60c3703ac76063107a2a10fbdb9a1c880596f88 (diff) | |
| download | emacs-24510c22a36564fe6c4b6f79a30fc41fee89b45b.tar.gz emacs-24510c22a36564fe6c4b6f79a30fc41fee89b45b.zip | |
* lisp/files.el (find-file): Don't use force-same-window.
* lisp/window.el (switch-to-buffer): Better match Emacs-23 behavior and only
use pop-to-buffer if the selected window can't be used.
(pop-to-buffer-same-window): Use display-buffer--same-window-action.
Fixes: debbugs:10144
| -rw-r--r-- | lisp/ChangeLog | 7 | ||||
| -rw-r--r-- | lisp/files.el | 2 | ||||
| -rw-r--r-- | lisp/window.el | 43 |
3 files changed, 32 insertions, 20 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 7dabb7db106..2aded765af5 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2011-11-28 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * files.el (find-file): Don't use force-same-window (bug#10144). | ||
| 4 | * window.el (switch-to-buffer): Better match Emacs-23 behavior and only | ||
| 5 | use pop-to-buffer if the selected window can't be used. | ||
| 6 | (pop-to-buffer-same-window): Use display-buffer--same-window-action. | ||
| 7 | |||
| 1 | 2011-11-28 Eli Zaretskii <eliz@gnu.org> | 8 | 2011-11-28 Eli Zaretskii <eliz@gnu.org> |
| 2 | 9 | ||
| 3 | * vc/diff-mode.el (diff-mode-map): Don't inherit 'z' => 'M-z' from | 10 | * vc/diff-mode.el (diff-mode-map): Don't inherit 'z' => 'M-z' from |
diff --git a/lisp/files.el b/lisp/files.el index 0f167ce3ffa..f903d2919a6 100644 --- a/lisp/files.el +++ b/lisp/files.el | |||
| @@ -1343,7 +1343,7 @@ automatically choosing a major mode, use \\[find-file-literally]." | |||
| 1343 | (let ((value (find-file-noselect filename nil nil wildcards))) | 1343 | (let ((value (find-file-noselect filename nil nil wildcards))) |
| 1344 | (if (listp value) | 1344 | (if (listp value) |
| 1345 | (mapcar 'switch-to-buffer (nreverse value)) | 1345 | (mapcar 'switch-to-buffer (nreverse value)) |
| 1346 | (switch-to-buffer value nil 'force-same-window)))) | 1346 | (switch-to-buffer value)))) |
| 1347 | 1347 | ||
| 1348 | (defun find-file-other-window (filename &optional wildcards) | 1348 | (defun find-file-other-window (filename &optional wildcards) |
| 1349 | "Edit file FILENAME, in another window. | 1349 | "Edit file FILENAME, in another window. |
diff --git a/lisp/window.el b/lisp/window.el index 35d80e30ee3..69276a839bd 100644 --- a/lisp/window.el +++ b/lisp/window.el | |||
| @@ -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 |
| @@ -4945,10 +4951,7 @@ the buffer. | |||
| 4945 | 4951 | ||
| 4946 | 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 |
| 4947 | the list of recently selected ones." | 4953 | the list of recently selected ones." |
| 4948 | (pop-to-buffer buffer | 4954 | (pop-to-buffer buffer display-buffer--same-window-action norecord)) |
| 4949 | '(display-buffer-same-window | ||
| 4950 | (inhibit-same-window . nil)) | ||
| 4951 | norecord)) | ||
| 4952 | 4955 | ||
| 4953 | (defun read-buffer-to-switch (prompt) | 4956 | (defun read-buffer-to-switch (prompt) |
| 4954 | "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. |
| @@ -5013,21 +5016,23 @@ Return the buffer switched to." | |||
| 5013 | (interactive | 5016 | (interactive |
| 5014 | (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)) |
| 5015 | (let ((buffer (window-normalize-buffer-to-switch-to buffer-or-name))) | 5018 | (let ((buffer (window-normalize-buffer-to-switch-to buffer-or-name))) |
| 5016 | (if (null force-same-window) | 5019 | (cond |
| 5017 | (pop-to-buffer buffer display-buffer--same-window-action norecord) | 5020 | ;; Don't call set-window-buffer if it's not needed since it |
| 5018 | (cond | 5021 | ;; might signal an error (e.g. if the window is dedicated). |
| 5019 | ;; Don't call set-window-buffer if it's not needed since it | 5022 | ((eq buffer (window-buffer))) |
| 5020 | ;; might signal an error (e.g. if the window is dedicated). | 5023 | ((window-minibuffer-p) |
| 5021 | ((eq buffer (window-buffer))) | 5024 | (if force-same-window |
| 5022 | ((window-minibuffer-p) | 5025 | (error "Cannot switch buffers in minibuffer window") |
| 5023 | (error "Cannot switch buffers in minibuffer window")) | 5026 | (pop-to-buffer buffer norecord))) |
| 5024 | ((eq (window-dedicated-p) t) | 5027 | ((eq (window-dedicated-p) t) |
| 5025 | (error "Cannot switch buffers in a dedicated window")) | 5028 | (if force-same-window |
| 5026 | (t (set-window-buffer nil buffer))) | 5029 | (error "Cannot switch buffers in a dedicated window") |
| 5027 | 5030 | (pop-to-buffer buffer norecord))) | |
| 5028 | (unless norecord | 5031 | (t (set-window-buffer nil buffer))) |
| 5029 | (select-window (selected-window))) | 5032 | |
| 5030 | (set-buffer buffer)))) | 5033 | (unless norecord |
| 5034 | (select-window (selected-window))) | ||
| 5035 | (set-buffer buffer))) | ||
| 5031 | 5036 | ||
| 5032 | (defun switch-to-buffer-other-window (buffer-or-name &optional norecord) | 5037 | (defun switch-to-buffer-other-window (buffer-or-name &optional norecord) |
| 5033 | "Select the buffer specified by BUFFER-OR-NAME in another window. | 5038 | "Select the buffer specified by BUFFER-OR-NAME in another window. |