By default, a *scratch*
buffer is created when Emacs starts. The initial *scratch*
buffer contains the following message by default:
;; 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.
This message appears to be set by the variable initial-scratch-message
.
If I kill (C-x k
) the initial scratch buffer and recreate it using C-x b *scratch*
, the new scratch buffer will be blank. It will not contain the initial-scratch-message
. This is not what I want. I want to see the message. How do I configure all scratch buffers to contain initial-scratch-message
when they are recreated?
(insert ...)
to insert text wherever you want, just run a test to see whether the buffer already exists so you don't insert the same text twice. emacs.stackexchange.com/a/16493/2287 You can modify the example to make it be whatevermajor-mode
you want, or even justfundamental-mode
if so desired. When the*scratch*
buffer is created automatically by Emacs, you may wish to use a custom function attached to the variableinitial-major-mode
which does more than just set major-mode.C-x b *scratch*
", the O.P. is merely creating a new generic/vanilla buffer with no particular major-mode. It is just like creating a new buffer named*foo*
or*bar*
or*baz*
. The question, as written, seems to imply that the O.P. believes the newly created buffer named*scratch*
may have had some special relationship to the initial*scratch*
buffer beyond having the same buffer-name.C-x b *scratch*
, I get a Lisp interaction mode buffer. I am using GNU Emacs 25.2.2.set-buffer-major-mode
withinbuffer.c
will run the function attached to theinitial-major-mode
variable if the buffer-name is*scratch*
. The Lisp functionwindow-normalize-buffer-to-switch-to
withinwindow.el
callsset-buffer-major-mode
. Therefore, creating a custom function and attaching it to theinitial-major-mode
variable seems like the most appropriate course of action given your desire to use the buffer-name*scratch*
. Thank you for providing me with the opportunity/incentive to trace the aforementioned items.