emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master dafd329: * lisp/window.el (next-buffer, previous-bu


From: Juri Linkov
Subject: [Emacs-diffs] master dafd329: * lisp/window.el (next-buffer, previous-buffer): Add repeat count arg.
Date: Sun, 13 Oct 2019 17:19:03 -0400 (EDT)

branch: master
commit dafd329771f5028cdac1a2691a236ffa296c360c
Author: Juri Linkov <address@hidden>
Commit: Juri Linkov <address@hidden>

    * 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 269f9f7..74e6211 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 ada7af3..d9d895a 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 <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.
 
diff --git a/lisp/window.el b/lisp/window.el
index d795520..80d9d2e 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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]