From dafd329771f5028cdac1a2691a236ffa296c360c Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Mon, 14 Oct 2019 00:18:56 +0300 Subject: [PATCH] * lisp/window.el (next-buffer, previous-buffer): Add repeat count arg. * doc/emacs/buffers.texi (Select Buffer): Mention arg as repeat count. (Bug#37514) --- doc/emacs/buffers.texi | 3 ++- etc/NEWS | 7 ++++--- lisp/window.el | 18 ++++++++++-------- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/doc/emacs/buffers.texi b/doc/emacs/buffers.texi index 269f9f7d6fe..74e6211f808 100644 --- a/doc/emacs/buffers.texi +++ b/doc/emacs/buffers.texi @@ -127,7 +127,8 @@ Modes}). (@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 diff --git a/etc/NEWS b/etc/NEWS index ada7af37469..d9d895ac816 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -2115,9 +2115,10 @@ The new command 'global-tab-line-mode' enables the tab line above each window, which you can use to switch buffers in the window. Selecting the previous window-local tab is the same as typing 'C-x ' (previous-buffer), selecting the next tab is the same as 'C-x ' -(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. diff --git a/lisp/window.el b/lisp/window.el index d7955209cd4..80d9d2e072b 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -4747,31 +4747,33 @@ displayed there." (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. -- 2.39.2