; Warn about killed buffers returned by 'window-prev-buffers' (Bug#81370)

* src/window.c (Fwindow_prev_buffers): In doc-string mention
that the return value may reference killed buffers.
* doc/lispref/windows.texi (Window History): Mention that the
return value of 'window-prev-buffers' may reference buffers that
have been killed.
This commit is contained in:
Martin Rudalics 2026-07-07 09:50:45 +02:00
parent b07e634e4c
commit 924d88a736
2 changed files with 10 additions and 1 deletions

View file

@ -4939,6 +4939,11 @@ and @var{window-pos} is a marker that gives the window point position
The list is ordered so that earlier elements correspond to more
recently-shown buffers, and the first element usually corresponds to the
buffer most recently removed from the window.
As a rule, elements are removed from this list when their buffer gets
killed. In rare cases, however, elements may have survived the killing
of their buffer. It's a good idea therefore to always check buffers for
liveness when processing the return value of this function.
@end defun
@defun set-window-prev-buffers window prev-buffers

View file

@ -2326,7 +2326,11 @@ WINDOW must be a live window and defaults to the selected one.
The return value is a list of elements (BUFFER WINDOW-START POS),
where BUFFER is a buffer, WINDOW-START is the start position of the
window for that buffer, and POS is a window-specific point value. */)
window for that buffer, and POS is a window-specific point value.
In rare ocasions BUFFER may have been already killed. It's therefore
advisable to always check the return value for the occurrence of dead
buffers before using it. */)
(Lisp_Object window)
{
return decode_live_window (window)->prev_buffers;