unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#16024: 24.3.50; [PATCH] `switch-to-buffer*': prefix arg kills original buffer
@ 2013-12-02  3:04 Drew Adams
  2014-02-10  4:08 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 4+ messages in thread
From: Drew Adams @ 2013-12-02  3:04 UTC (permalink / raw)
  To: 16024

[-- Attachment #1: Type: text/plain, Size: 473 bytes --]

The attached patch makes `switch-to-buffer(-other-(window|frame))'
with a prefix arg act analogously to `find-alternate-file': the buffer
current before the switch is killed.

In GNU Emacs 24.3.50.2 (i686-pc-mingw32)
 of 2013-11-28 on LEG570
Bzr revision: 115271 rgm@gnu.org-20131128203155-qjc1xsp19z2k64b2
Windowing system distributor `Microsoft Corp.', version 6.1.7601
Configured using:
 `configure --enable-checking 'CFLAGS=-O0 -g3' CPPFLAGS=-DGLYPH_DEBUG=1'

[-- Attachment #2: window-2013-12-01.patch --]
[-- Type: application/octet-stream, Size: 7936 bytes --]

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))
  \f
  (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)))
  \f
  (defun set-window-text-height (window height)
    "Set the height in lines of the text display area of WINDOW to HEIGHT.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#16024: 24.3.50; [PATCH] `switch-to-buffer*': prefix arg kills original buffer
  2013-12-02  3:04 bug#16024: 24.3.50; [PATCH] `switch-to-buffer*': prefix arg kills original buffer Drew Adams
@ 2014-02-10  4:08 ` Lars Ingebrigtsen
  2014-02-10  5:20   ` Drew Adams
  0 siblings, 1 reply; 4+ messages in thread
From: Lars Ingebrigtsen @ 2014-02-10  4:08 UTC (permalink / raw)
  To: Drew Adams; +Cc: 16024

Drew Adams <drew.adams@oracle.com> writes:

> The attached patch makes `switch-to-buffer(-other-(window|frame))'
> with a prefix arg act analogously to `find-alternate-file': the buffer
> current before the switch is killed.

Hm...  what's the use case?

-- 
(domestic pets only, the antidote for overdose, milk.)
  bloggy blog http://lars.ingebrigtsen.no/





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#16024: 24.3.50; [PATCH] `switch-to-buffer*': prefix arg kills original buffer
  2014-02-10  4:08 ` Lars Ingebrigtsen
@ 2014-02-10  5:20   ` Drew Adams
  2014-02-11 11:56     ` Lars Ingebrigtsen
  0 siblings, 1 reply; 4+ messages in thread
From: Drew Adams @ 2014-02-10  5:20 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 16024

> > The attached patch makes `switch-to-buffer(-other-(window|frame))'
> > with a prefix arg act analogously to `find-alternate-file': the
> > buffer current before the switch is killed.
> 
> Hm...  what's the use case?

Just what it says: kill the current buffer and switch to another.

Same use case as for `find-alternate-file', but for any buffer,
not just a file buffer.





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#16024: 24.3.50; [PATCH] `switch-to-buffer*': prefix arg kills original buffer
  2014-02-10  5:20   ` Drew Adams
@ 2014-02-11 11:56     ` Lars Ingebrigtsen
  0 siblings, 0 replies; 4+ messages in thread
From: Lars Ingebrigtsen @ 2014-02-11 11:56 UTC (permalink / raw)
  To: Drew Adams; +Cc: 16024

Drew Adams <drew.adams@oracle.com> writes:

>> > The attached patch makes `switch-to-buffer(-other-(window|frame))'
>> > with a prefix arg act analogously to `find-alternate-file': the
>> > buffer current before the switch is killed.
>> 
>> Hm...  what's the use case?
>
> Just what it says: kill the current buffer and switch to another.
>
> Same use case as for `find-alternate-file', but for any buffer,
> not just a file buffer.

Adding a prefix to a gazillion buffer switching commands (to kill the
buffer you're in) doesn't seem like a "use case".

-- 
(domestic pets only, the antidote for overdose, milk.)
  bloggy blog http://lars.ingebrigtsen.no/





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-02-11 11:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-02  3:04 bug#16024: 24.3.50; [PATCH] `switch-to-buffer*': prefix arg kills original buffer Drew Adams
2014-02-10  4:08 ` Lars Ingebrigtsen
2014-02-10  5:20   ` Drew Adams
2014-02-11 11:56     ` Lars Ingebrigtsen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).