Subject: bug#55257: master f2d2fe6fc8: server-execute: Initialize the *scratch* buffer

From: Sean Whitton <[email-masked]>
Date: Fri, 06 May 2022 12:20:11 -0700

Hello Stefan,

On Fri 06 May 2022 at 07:34am -04, Stefan Monnier wrote:

>> +  (if-let ((scratch (get-buffer "*scratch*")))
>> +      scratch
>
> A.k.a
>
>      (or (get-buffer "*scratch*")

Ah yes.

>>  (defun scratch-buffer ()
>>    "Switch to the \*scratch\* buffer.
>>  If the buffer doesn't exist, create it first."
>>    (interactive)
>> -  (if (get-buffer "*scratch*")
>> -      (pop-to-buffer-same-window "*scratch*")
>> -    (pop-to-buffer-same-window (get-buffer-create "*scratch*"))
>> -    (when initial-scratch-message
>> -      (insert initial-scratch-message))
>> -    (funcall initial-major-mode)))
>> +  (pop-to-buffer-same-window (get-initial-buffer-create)))
>
> I think the new function can be considered "internal", and I think it
> would be better for its name to use "scratch-buffer" as a prefix, so
> maybe `scratch-buffer--create`?

It gets called in places like server.el, though.  And I can imagine
wanting to use it in third party code as a better version of
(get-buffer-create "*scratch"*).  So it seems to me not to be internal.

-- 
Sean Whitton