(@code{previous-buffer}) selects the previous buffer (following the
order of most recent selection in the current frame), while @kbd{C-x
@key{RIGHT}} (@code{next-buffer}) moves through buffers in the reverse
-direction.
+direction. Both commands support a numeric prefix argument that
+serves as a repeat count.
@kindex C-x 4 b
@findex switch-to-buffer-other-window
window, which you can use to switch buffers in the window. Selecting
the previous window-local tab is the same as typing 'C-x <LEFT>'
(previous-buffer), selecting the next tab is the same as 'C-x <RIGHT>'
-(next-buffer). Clicking on the plus icon adds a new buffer to the
-window-local tab line of buffers. Using the mouse wheel on the
-tab line scrolls tabs that display the window buffers.
+(next-buffer). Both commands support a numeric prefix argument as
+a repeat count. Clicking on the plus icon adds a new buffer to the
+window-local tab line of buffers. Using the mouse wheel on the tab
+line scrolls tabs that display the window buffers.
** fileloop.el lets one setup multifile operations like search&replace.
(interactive)
(switch-to-buffer (last-buffer)))
-(defun next-buffer ()
- "In selected window switch to next buffer.
+(defun next-buffer (&optional arg)
+ "In selected window switch to ARGth next buffer.
Call `switch-to-next-buffer' unless the selected window is the
minibuffer window or is dedicated to its buffer."
- (interactive)
+ (interactive "p")
(cond
((window-minibuffer-p)
(user-error "Cannot switch buffers in minibuffer window"))
((eq (window-dedicated-p) t)
(user-error "Window is strongly dedicated to its buffer"))
(t
- (switch-to-next-buffer))))
+ (dotimes (_ (or arg 1))
+ (switch-to-next-buffer)))))
-(defun previous-buffer ()
- "In selected window switch to previous buffer.
+(defun previous-buffer (&optional arg)
+ "In selected window switch to ARGth previous buffer.
Call `switch-to-prev-buffer' unless the selected window is the
minibuffer window or is dedicated to its buffer."
- (interactive)
+ (interactive "p")
(cond
((window-minibuffer-p)
(user-error "Cannot switch buffers in minibuffer window"))
((eq (window-dedicated-p) t)
(user-error "Window is strongly dedicated to its buffer"))
(t
- (switch-to-prev-buffer))))
+ (dotimes (_ (or arg 1))
+ (switch-to-prev-buffer)))))
(defun delete-windows-on (&optional buffer-or-name frame)
"Delete all windows showing BUFFER-OR-NAME.