[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/trunk r105179: Add FORCE-SAME-WINDOW argume
From: |
Chong Yidong |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/trunk r105179: Add FORCE-SAME-WINDOW argument to switch-to-buffer. |
Date: |
Wed, 13 Jul 2011 18:00:48 -0400 |
User-agent: |
Bazaar (2.3.1) |
------------------------------------------------------------
revno: 105179
committer: Chong Yidong <address@hidden>
branch nick: trunk
timestamp: Wed 2011-07-13 18:00:48 -0400
message:
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.
modified:
etc/NEWS
lisp/ChangeLog
lisp/emacs-lisp/bytecomp.el
lisp/window.el
=== modified file 'etc/NEWS'
--- a/etc/NEWS 2011-07-12 04:54:15 +0000
+++ b/etc/NEWS 2011-07-13 22:00:48 +0000
@@ -986,6 +986,15 @@
* Lisp changes in Emacs 24.1
+** Window changes
+
+*** `switch-to-buffer' has a new optional argument FORCE-SAME-WINDOW,
+which if non-nil requires the buffer to be displayed in the currently
+selected window, signaling an error otherwise. If nil, another window
+can be used, e.g. if the selected one is strongly dedicated.
+
+*** FIXME: buffer-display-alist changes
+
** Completion
*** New variable completion-extra-properties used to specify extra properties
of the current completion:
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog 2011-07-13 21:53:41 +0000
+++ b/lisp/ChangeLog 2011-07-13 22:00:48 +0000
@@ -1,3 +1,11 @@
+2011-07-13 Chong Yidong <address@hidden>
+
+ * window.el (switch-to-buffer): New arg FORCE-SAME-WINDOW. Use
+ pop-to-buffer buffer-or-name if it is nil.
+
+ * emacs-lisp/bytecomp.el (byte-compile-interactive-only-functions):
+ Remove switch-to-buffer.
+
2011-07-13 Lars Magne Ingebrigtsen <address@hidden>
* startup.el (initial-buffer-choice): Add `none' as a choice
=== modified file 'lisp/emacs-lisp/bytecomp.el'
--- a/lisp/emacs-lisp/bytecomp.el 2011-07-04 16:08:16 +0000
+++ b/lisp/emacs-lisp/bytecomp.el 2011-07-13 22:00:48 +0000
@@ -355,7 +355,7 @@
(defvar byte-compile-interactive-only-functions
'(beginning-of-buffer end-of-buffer replace-string replace-regexp
insert-file insert-buffer insert-file-literally previous-line next-line
- goto-line comint-run delete-backward-char switch-to-buffer)
+ goto-line comint-run delete-backward-char)
"List of commands that are not meant to be called from Lisp.")
(defvar byte-compile-not-obsolete-vars nil
=== modified file 'lisp/window.el'
--- a/lisp/window.el 2011-07-10 12:41:47 +0000
+++ b/lisp/window.el 2011-07-13 22:00:48 +0000
@@ -5925,7 +5925,7 @@
buffer))
(other-buffer)))
-(defun switch-to-buffer (buffer-or-name &optional norecord)
+(defun switch-to-buffer (buffer-or-name &optional norecord force-same-window)
"Switch to buffer BUFFER-OR-NAME in the selected window.
If called interactively, prompt for the buffer name using the
minibuffer. The variable `confirm-nonexistent-file-or-buffer'
@@ -5941,25 +5941,33 @@
Optional argument NORECORD non-nil means do not put the buffer
specified by BUFFER-OR-NAME at the front of the buffer list and
do not make the window displaying it the most recently selected
-one. Return the buffer switched to.
-
-This function is intended for interactive use only. Lisp
-functions should call `pop-to-buffer-same-window' instead."
+one.
+
+If FORCE-SAME-WINDOW is non-nil, BUFFER-OR-NAME must be displayed
+in the currently selected window; signal an error if that is
+impossible (e.g. if the selected window is minibuffer-only).
+If non-nil, BUFFER-OR-NAME may be displayed in another window.
+
+Return the buffer switched to."
(interactive
- (list (read-buffer-to-switch "Switch to buffer: ")))
+ (list (read-buffer-to-switch "Switch to buffer: ") nil nil))
(let ((buffer (window-normalize-buffer-to-switch-to buffer-or-name)))
- (cond
- ;; Don't call set-window-buffer if it's not needed since it
- ;; might signal an error (e.g. if the window is dedicated).
- ((eq buffer (window-buffer)) nil)
- ((window-minibuffer-p)
- (error "Cannot switch buffers in minibuffer window"))
- ((eq (window-dedicated-p) t)
- (error "Cannot switch buffers in a dedicated window"))
- (t (set-window-buffer nil buffer)))
- (unless norecord
- (select-window (selected-window)))
- (set-buffer buffer)))
+ (if (null force-same-window)
+ (pop-to-buffer buffer-or-name
+ '(same-window (reuse-window-dedicated . weak))
+ norecord nil)
+ (cond
+ ;; Don't call set-window-buffer if it's not needed since it
+ ;; might signal an error (e.g. if the window is dedicated).
+ ((eq buffer (window-buffer)) nil)
+ ((window-minibuffer-p)
+ (error "Cannot switch buffers in minibuffer window"))
+ ((eq (window-dedicated-p) t)
+ (error "Cannot switch buffers in a dedicated window"))
+ (t (set-window-buffer nil buffer)))
+ (unless norecord
+ (select-window (selected-window)))
+ (set-buffer buffer))))
(defun switch-to-buffer-same-frame (buffer-or-name &optional norecord)
"Switch to buffer BUFFER-OR-NAME in a window on the selected frame.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] /srv/bzr/emacs/trunk r105179: Add FORCE-SAME-WINDOW argument to switch-to-buffer.,
Chong Yidong <=