1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-24 14:30:43 -08:00

A better fix for bug#60096

* lisp/startup.el (initial-scratch-message):
* lisp/simple.el (get-scratch-buffer-create): Revert last changes.

* src/window.c (Fset_window_configuration): Force recalculation of
Vwindow_list after restoring the windows.
* src/buffer.c (other_buffer_safely): Make sure we always return a
valid buffer, even if 'get-scratch-buffer-create' signals an
error.
This commit is contained in:
Eli Zaretskii 2022-12-16 16:29:51 +02:00
parent 1b9ca1e5e6
commit 89f54e8157
4 changed files with 23 additions and 9 deletions

View file

@ -10683,12 +10683,7 @@ too short to have a dst element.
;; we just created it.
(with-current-buffer scratch
(when initial-scratch-message
;; We used to run this through substitute-command-keys,
;; but that might be unsafe in some rare cases, and this
;; function must never fail and signal an error, because
;; it is called from other_buffer_safely, which must
;; always produce a valid buffer.
(insert initial-scratch-message)
(insert (substitute-command-keys initial-scratch-message))
(set-buffer-modified-p nil))
(funcall initial-major-mode))
scratch)))

View file

@ -1669,7 +1669,7 @@ Changed settings will be marked as \"CHANGED outside of Customize\"."
(defcustom initial-scratch-message (purecopy "\
;; This buffer is for text that is not saved, and for Lisp evaluation.
;; To create a file, visit it with \"C-x C-f\" and enter text in its buffer.
;; To create a file, visit it with \\[find-file] and enter text in its buffer.
")
"Initial documentation displayed in *scratch* buffer at startup.

View file

@ -1747,7 +1747,18 @@ other_buffer_safely (Lisp_Object buffer)
if (candidate_buffer (buf, buffer))
return buf;
return safe_call (1, Qget_scratch_buffer_create);
/* This function must return a valid buffer, since it is frequently
our last line of defense in the face of the expected buffers
becoming dead under our feet. safe_call below could return nil
if recreating *scratch* in Lisp, which does some fancy stuff,
signals an error in some weird use case. */
buf = safe_call (1, Qget_scratch_buffer_create);
if (NILP (buf))
{
AUTO_STRING (scratch, "*scratch*");
buf = Fget_buffer_create (scratch, Qnil);
}
return buf;
}
DEFUN ("buffer-enable-undo", Fbuffer_enable_undo, Sbuffer_enable_undo,

View file

@ -2639,7 +2639,7 @@ window_list (void)
Lisp_Object arglist = Qnil;
/* We are visiting windows in canonical order, and add
new windows at the front of args[1], which means we
new windows at the front of arglist, which means we
have to reverse this list at the end. */
foreach_window (XFRAME (frame), add_window_to_list, &arglist);
arglist = Fnreverse (arglist);
@ -7329,6 +7329,14 @@ the return value is nil. Otherwise the value is t. */)
last_selected_window)
= selected_window;
/* We may have deleted windows above. Then again, maybe we
haven't: the functions we call to maybe delete windows can
decide a window cannot be deleted. Force recalculation of
Vwindow_list next time it is needed, to make sure stale
windows with no buffers don't escape into the wild, which
will cause crashes elsewhere. */
Vwindow_list = Qnil;
if (NILP (data->focus_frame)
|| (FRAMEP (data->focus_frame)
&& FRAME_LIVE_P (XFRAME (data->focus_frame))))