From e495dbea7035bcb1f26ed82f0d56a5abc90974fa Mon Sep 17 00:00:00 2001 From: Juanma Barranquero Date: Tue, 26 Nov 2019 15:03:57 +0100 Subject: [PATCH] (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. --- etc/NEWS | 4 ++++ lisp/window.el | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 2a14eb2ecfc..d3331daf17f 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -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 diff --git a/lisp/window.el b/lisp/window.el index 49fad75d3cd..c8a5816b8c9 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -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. -- 2.39.5