Commit e495dbea authored by Juanma Barranquero's avatar Juanma Barranquero

(next|previous)-buffer no longer fail silently (bug#38384)

* lisp/window.el (next-buffer, previous-buffer):
Signal 'user-error' if there is no buffer to switch to.

* etc/NEWS: Document it.
parent 90a7cd07
...@@ -2620,6 +2620,10 @@ scrolling. ...@@ -2620,6 +2620,10 @@ scrolling.
** help-follow-symbol now signals 'user-error' if point (or the ** help-follow-symbol now signals 'user-error' if point (or the
position pointed to by the argument POS) is not in a symbol. position pointed to by the argument POS) is not in a symbol.
---
*** next-buffer and previous-buffer now signal 'user-error' if there
is no buffer to switch to.
* Lisp Changes in Emacs 27.1 * Lisp Changes in Emacs 27.1
......
...@@ -4850,7 +4850,8 @@ minibuffer window or is dedicated to its buffer." ...@@ -4850,7 +4850,8 @@ minibuffer window or is dedicated to its buffer."
(user-error "Window is strongly dedicated to its buffer")) (user-error "Window is strongly dedicated to its buffer"))
(t (t
(dotimes (_ (or arg 1)) (dotimes (_ (or arg 1))
(switch-to-next-buffer))))) (unless (switch-to-next-buffer)
(user-error "No next buffer"))))))
(defun previous-buffer (&optional arg) (defun previous-buffer (&optional arg)
"In selected window switch to ARGth previous buffer. "In selected window switch to ARGth previous buffer.
...@@ -4864,7 +4865,8 @@ minibuffer window or is dedicated to its buffer." ...@@ -4864,7 +4865,8 @@ minibuffer window or is dedicated to its buffer."
(user-error "Window is strongly dedicated to its buffer")) (user-error "Window is strongly dedicated to its buffer"))
(t (t
(dotimes (_ (or arg 1)) (dotimes (_ (or arg 1))
(switch-to-prev-buffer))))) (unless (switch-to-prev-buffer)
(user-error "No previous buffer"))))))
(defun delete-windows-on (&optional buffer-or-name frame) (defun delete-windows-on (&optional buffer-or-name frame)
"Delete all windows showing BUFFER-OR-NAME. "Delete all windows showing BUFFER-OR-NAME.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment