aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChong Yidong2011-07-13 18:00:48 -0400
committerChong Yidong2011-07-13 18:00:48 -0400
commitbee0fcef3d9c332b9907369b4e6f6f61d6fbdf35 (patch)
treef99c4d0a39a961e9f281c1825c43810d89157797
parent0f04b32ce1d0f6f6e94b77931122acf3da3b3680 (diff)
downloademacs-bee0fcef3d9c332b9907369b4e6f6f61d6fbdf35.tar.gz
emacs-bee0fcef3d9c332b9907369b4e6f6f61d6fbdf35.zip
Add FORCE-SAME-WINDOW argument to switch-to-buffer.
* lisp/window.el (switch-to-buffer): New arg FORCE-SAME-WINDOW. Use pop-to-buffer buffer-or-name if it is nil. * lisp/emacs-lisp/bytecomp.el (byte-compile-interactive-only-functions): Remove switch-to-buffer.
-rw-r--r--etc/NEWS9
-rw-r--r--lisp/ChangeLog8
-rw-r--r--lisp/emacs-lisp/bytecomp.el2
-rw-r--r--lisp/window.el42
4 files changed, 43 insertions, 18 deletions
diff --git a/etc/NEWS b/etc/NEWS
index 8a37735b41f..3f23c23fe3a 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -986,6 +986,15 @@ sc.el, x-menu.el, rnews.el, rnewspost.el
986 986
987* Lisp changes in Emacs 24.1 987* Lisp changes in Emacs 24.1
988 988
989** Window changes
990
991*** `switch-to-buffer' has a new optional argument FORCE-SAME-WINDOW,
992which if non-nil requires the buffer to be displayed in the currently
993selected window, signaling an error otherwise. If nil, another window
994can be used, e.g. if the selected one is strongly dedicated.
995
996*** FIXME: buffer-display-alist changes
997
989** Completion 998** Completion
990*** New variable completion-extra-properties used to specify extra properties 999*** New variable completion-extra-properties used to specify extra properties
991of the current completion: 1000of the current completion:
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 86bc82f3ecd..17cbc948536 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,11 @@
12011-07-13 Chong Yidong <cyd@stupidchicken.com>
2
3 * window.el (switch-to-buffer): New arg FORCE-SAME-WINDOW. Use
4 pop-to-buffer buffer-or-name if it is nil.
5
6 * emacs-lisp/bytecomp.el (byte-compile-interactive-only-functions):
7 Remove switch-to-buffer.
8
12011-07-13 Lars Magne Ingebrigtsen <larsi@gnus.org> 92011-07-13 Lars Magne Ingebrigtsen <larsi@gnus.org>
2 10
3 * startup.el (initial-buffer-choice): Add `none' as a choice 11 * startup.el (initial-buffer-choice): Add `none' as a choice
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index 223e9667ac3..127f93c6858 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -355,7 +355,7 @@ else the global value will be modified."
355(defvar byte-compile-interactive-only-functions 355(defvar byte-compile-interactive-only-functions
356 '(beginning-of-buffer end-of-buffer replace-string replace-regexp 356 '(beginning-of-buffer end-of-buffer replace-string replace-regexp
357 insert-file insert-buffer insert-file-literally previous-line next-line 357 insert-file insert-buffer insert-file-literally previous-line next-line
358 goto-line comint-run delete-backward-char switch-to-buffer) 358 goto-line comint-run delete-backward-char)
359 "List of commands that are not meant to be called from Lisp.") 359 "List of commands that are not meant to be called from Lisp.")
360 360
361(defvar byte-compile-not-obsolete-vars nil 361(defvar byte-compile-not-obsolete-vars nil
diff --git a/lisp/window.el b/lisp/window.el
index 999e408bdb1..593fa14d215 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -5925,7 +5925,7 @@ buffer with the name BUFFER-OR-NAME and return that buffer."
5925 buffer)) 5925 buffer))
5926 (other-buffer))) 5926 (other-buffer)))
5927 5927
5928(defun switch-to-buffer (buffer-or-name &optional norecord) 5928(defun switch-to-buffer (buffer-or-name &optional norecord force-same-window)
5929 "Switch to buffer BUFFER-OR-NAME in the selected window. 5929 "Switch to buffer BUFFER-OR-NAME in the selected window.
5930If called interactively, prompt for the buffer name using the 5930If called interactively, prompt for the buffer name using the
5931minibuffer. The variable `confirm-nonexistent-file-or-buffer' 5931minibuffer. The variable `confirm-nonexistent-file-or-buffer'
@@ -5941,25 +5941,33 @@ BUFFER-OR-NAME is nil, switch to the buffer returned by
5941Optional argument NORECORD non-nil means do not put the buffer 5941Optional argument NORECORD non-nil means do not put the buffer
5942specified by BUFFER-OR-NAME at the front of the buffer list and 5942specified by BUFFER-OR-NAME at the front of the buffer list and
5943do not make the window displaying it the most recently selected 5943do not make the window displaying it the most recently selected
5944one. Return the buffer switched to. 5944one.
5945 5945
5946This function is intended for interactive use only. Lisp 5946If FORCE-SAME-WINDOW is non-nil, BUFFER-OR-NAME must be displayed
5947functions should call `pop-to-buffer-same-window' instead." 5947in the currently selected window; signal an error if that is
5948impossible (e.g. if the selected window is minibuffer-only).
5949If non-nil, BUFFER-OR-NAME may be displayed in another window.
5950
5951Return the buffer switched to."
5948 (interactive 5952 (interactive
5949 (list (read-buffer-to-switch "Switch to buffer: "))) 5953 (list (read-buffer-to-switch "Switch to buffer: ") nil nil))
5950 (let ((buffer (window-normalize-buffer-to-switch-to buffer-or-name))) 5954 (let ((buffer (window-normalize-buffer-to-switch-to buffer-or-name)))
5951 (cond 5955 (if (null force-same-window)
5952 ;; Don't call set-window-buffer if it's not needed since it 5956 (pop-to-buffer buffer-or-name
5953 ;; might signal an error (e.g. if the window is dedicated). 5957 '(same-window (reuse-window-dedicated . weak))
5954 ((eq buffer (window-buffer)) nil) 5958 norecord nil)
5955 ((window-minibuffer-p) 5959 (cond
5956 (error "Cannot switch buffers in minibuffer window")) 5960 ;; Don't call set-window-buffer if it's not needed since it
5957 ((eq (window-dedicated-p) t) 5961 ;; might signal an error (e.g. if the window is dedicated).
5958 (error "Cannot switch buffers in a dedicated window")) 5962 ((eq buffer (window-buffer)) nil)
5959 (t (set-window-buffer nil buffer))) 5963 ((window-minibuffer-p)
5960 (unless norecord 5964 (error "Cannot switch buffers in minibuffer window"))
5961 (select-window (selected-window))) 5965 ((eq (window-dedicated-p) t)
5962 (set-buffer buffer))) 5966 (error "Cannot switch buffers in a dedicated window"))
5967 (t (set-window-buffer nil buffer)))
5968 (unless norecord
5969 (select-window (selected-window)))
5970 (set-buffer buffer))))
5963 5971
5964(defun switch-to-buffer-same-frame (buffer-or-name &optional norecord) 5972(defun switch-to-buffer-same-frame (buffer-or-name &optional norecord)
5965 "Switch to buffer BUFFER-OR-NAME in a window on the selected frame. 5973 "Switch to buffer BUFFER-OR-NAME in a window on the selected frame.