(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.
This commit is contained in:
Juanma Barranquero 2019-11-26 15:03:57 +01:00
parent 90a7cd073b
commit e495dbea70
2 changed files with 8 additions and 2 deletions

View file

@ -2620,6 +2620,10 @@ scrolling.
** help-follow-symbol now signals 'user-error' if point (or the
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

View file

@ -4850,7 +4850,8 @@ minibuffer window or is dedicated to its buffer."
(user-error "Window is strongly dedicated to its buffer"))
(t
(dotimes (_ (or arg 1))
(switch-to-next-buffer)))))
(unless (switch-to-next-buffer)
(user-error "No next buffer"))))))
(defun previous-buffer (&optional arg)
"In selected window switch to ARGth previous buffer.
@ -4864,7 +4865,8 @@ minibuffer window or is dedicated to its buffer."
(user-error "Window is strongly dedicated to its buffer"))
(t
(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)
"Delete all windows showing BUFFER-OR-NAME.