diff -cw window.el window-patched-2013-12-01.el
*** window.el	Sun Dec  1 18:40:12 2013
--- window-patched-2013-12-01.el	Sun Dec  1 18:52:15 2013
***************
*** 6442,6448 ****
    :group 'windows
    :version "24.3")
  
! (defun switch-to-buffer (buffer-or-name &optional norecord force-same-window)
    "Display buffer BUFFER-OR-NAME in the selected window.
  
  WARNING: This is NOT the way to work on another buffer temporarily
--- 6442,6448 ----
    :group 'windows
    :version "24.3")
  
! (defun switch-to-buffer (buffer-or-name &optional norecord force-same-window replace)
    "Display buffer BUFFER-OR-NAME in the selected window.
  
  WARNING: This is NOT the way to work on another buffer temporarily
***************
*** 6459,6464 ****
--- 6459,6467 ----
  determines whether to request confirmation before creating a new
  buffer.
  
+ With a prefix argument, kill the buffer that was current before the
+ switch.
+ 
  BUFFER-OR-NAME may be a buffer, a string (a buffer name), or nil.
  If BUFFER-OR-NAME is a string that does not identify an existing
  buffer, create a buffer with that name.  If BUFFER-OR-NAME is
***************
*** 6472,6485 ****
  must be displayed in the selected window; if that is impossible,
  signal an error rather than calling `pop-to-buffer'.
  
  The option `switch-to-buffer-preserve-window-point' can be used
  to make the buffer appear at its last position in the selected
  window.
  
  Return the buffer switched to."
    (interactive
!    (list (read-buffer-to-switch "Switch to buffer: ") nil 'force-same-window))
!   (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).
--- 6475,6497 ----
  must be displayed in the selected window; if that is impossible,
  signal an error rather than calling `pop-to-buffer'.
  
+ Optional argument REPLACE non-nil means kill the buffer that was
+ current before the switch.
+ 
  The option `switch-to-buffer-preserve-window-point' can be used
  to make the buffer appear at its last position in the selected
  window.
  
  Return the buffer switched to."
    (interactive
!    (list (read-buffer-to-switch (if current-prefix-arg
!                                     "Replace here with buffer: "
!                                   "Switch to buffer: "))
!          nil
!          'force-same-window
!          current-prefix-arg))
!   (let ((curr-buf (current-buffer))
!         (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).
***************
*** 6505,6516 ****
  	  ;; window (Bug#4041).
  	  (set-window-start (selected-window) (nth 1 entry) t)
  	  (set-window-point nil (nth 2 entry))))))
! 
      (unless norecord
        (select-window (selected-window)))
      (set-buffer buffer)))
  
! (defun switch-to-buffer-other-window (buffer-or-name &optional norecord)
    "Select the buffer specified by BUFFER-OR-NAME in another window.
  BUFFER-OR-NAME may be a buffer, a string (a buffer name), or
  nil.  Return the buffer switched to.
--- 6517,6528 ----
             ;; window (Bug#4041).
             (set-window-start (selected-window) (nth 1 entry) t)
             (set-window-point nil (nth 2 entry))))))
!     (when replace (kill-buffer curr-buf))
      (unless norecord
        (select-window (selected-window)))
      (set-buffer buffer)))
  
! (defun switch-to-buffer-other-window (buffer-or-name &optional norecord replace)
    "Select the buffer specified by BUFFER-OR-NAME in another window.
  BUFFER-OR-NAME may be a buffer, a string (a buffer name), or
  nil.  Return the buffer switched to.
***************
*** 6520,6525 ****
--- 6532,6540 ----
  determines whether to request confirmation before creating a new
  buffer.
  
+ With a prefix argument, kill the buffer that was current before the
+ switch.
+ 
  If BUFFER-OR-NAME is a string and does not identify an existing
  buffer, create a new buffer with that name.  If BUFFER-OR-NAME is
  nil, switch to the buffer returned by `other-buffer'.
***************
*** 6527,6540 ****
  Optional second argument NORECORD non-nil means do not put this
  buffer at the front of the list of recently selected ones.
  
  This uses the function `display-buffer' as a subroutine; see its
  documentation for additional customization information."
    (interactive
!    (list (read-buffer-to-switch "Switch to buffer in other window: ")))
!   (let ((pop-up-windows t))
      (pop-to-buffer buffer-or-name t norecord)))
  
! (defun switch-to-buffer-other-frame (buffer-or-name &optional norecord)
    "Switch to buffer BUFFER-OR-NAME in another frame.
  BUFFER-OR-NAME may be a buffer, a string (a buffer name), or
  nil.  Return the buffer switched to.
--- 6542,6564 ----
  Optional second argument NORECORD non-nil means do not put this
  buffer at the front of the list of recently selected ones.
  
+ Optional argument REPLACE non-nil means kill the buffer that was
+ current before the switch.
+ 
  This uses the function `display-buffer' as a subroutine; see its
  documentation for additional customization information."
    (interactive
!    (list (read-buffer-to-switch (if current-prefix-arg
!                                     "Replace with buffer (other window): "
!                                   "Switch to buffer in other window: "))
!          nil
!          current-prefix-arg))
!   (let ((curr-buf (current-buffer))
!         (pop-up-windows t))
!     (when replace (kill-buffer curr-buf))
      (pop-to-buffer buffer-or-name t norecord)))
  
! (defun switch-to-buffer-other-frame (buffer-or-name &optional norecord replace)
    "Switch to buffer BUFFER-OR-NAME in another frame.
  BUFFER-OR-NAME may be a buffer, a string (a buffer name), or
  nil.  Return the buffer switched to.
***************
*** 6544,6549 ****
--- 6568,6576 ----
  determines whether to request confirmation before creating a new
  buffer.
  
+ With a prefix argument, kill the buffer that was current before the
+ switch.
+ 
  If BUFFER-OR-NAME is a string and does not identify an existing
  buffer, create a new buffer with that name.  If BUFFER-OR-NAME is
  nil, switch to the buffer returned by `other-buffer'.
***************
*** 6551,6561 ****
  Optional second arg NORECORD non-nil means do not put this
  buffer at the front of the list of recently selected ones.
  
  This uses the function `display-buffer' as a subroutine; see its
  documentation for additional customization information."
    (interactive
!    (list (read-buffer-to-switch "Switch to buffer in other frame: ")))
!   (pop-to-buffer buffer-or-name display-buffer--other-frame-action norecord))
  
  (defun set-window-text-height (window height)
    "Set the height in lines of the text display area of WINDOW to HEIGHT.
--- 6578,6598 ----
  Optional second arg NORECORD non-nil means do not put this
  buffer at the front of the list of recently selected ones.
  
+ Optional argument REPLACE non-nil means kill the buffer that was
+ current before the switch.
+ 
  This uses the function `display-buffer' as a subroutine; see its
  documentation for additional customization information."
    (interactive
!    (list (read-buffer-to-switch (if current-prefix-arg
!                                     "Replace with buffer (other frame): "
!                                   "Switch to buffer in other frame: "))
!          nil
!          current-prefix-arg))
!   (let ((curr-buf (current-buffer))
!         (pop-up-windows t))
!     (when replace (kill-buffer curr-buf))
!     (pop-to-buffer buffer-or-name display-buffer--other-frame-action norecord)))
  
  (defun set-window-text-height (window height)
    "Set the height in lines of the text display area of WINDOW to HEIGHT.
