summaryrefslogtreecommitdiff
path: root/src/buffer.c
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2022-05-05 13:03:06 -0700
committerSean Whitton <spwhitton@spwhitton.name>2022-05-09 18:49:13 -0700
commit054062060e9f57fd037578378c23ad9ec294edac (patch)
treec9eaec1c5c4ce19e6be0c0c1000d0fb58bebd1b1 /src/buffer.c
parent54ab2b36740166d379c713e843870310f1ccf7a1 (diff)
Factor out *scratch* initialization
* lisp/simple.el (get-scratch-buffer-create): New function, factored out of scratch-buffer, and additionally clearing the modification flag and calling substitute-command-keys (bug#55257). (scratch-buffer): * lisp/server.el (server-execute): * lisp/startup.el (normal-no-mouse-startup-screen, command-line-1): * lisp/window.el (last-buffer, window-normalize-buffer-to-switch-to): * src/buffer.c (Fother_buffer, other_buffer_safely): Use it. (syms_of_buffer): Add Qget_scratch_buffer_create. * lisp/startup.el (startup--get-buffer-create-scratch): Delete now-unused function. * doc/lispref/os.texi (Summary: Sequence of Actions at Startup): * NEWS (Incompatible changes in Emacs 29.1): Document the change.
Diffstat (limited to 'src/buffer.c')
-rw-r--r--src/buffer.c22
1 files changed, 3 insertions, 19 deletions
diff --git a/src/buffer.c b/src/buffer.c
index f54714675e2..0f3061b4973 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -1665,16 +1665,7 @@ exists, return the buffer `*scratch*' (creating it if necessary). */)
if (!NILP (notsogood))
return notsogood;
else
- {
- AUTO_STRING (scratch, "*scratch*");
- buf = Fget_buffer (scratch);
- if (NILP (buf))
- {
- buf = Fget_buffer_create (scratch, Qnil);
- Fset_buffer_major_mode (buf);
- }
- return buf;
- }
+ return safe_call (1, Qget_scratch_buffer_create);
}
/* The following function is a safe variant of Fother_buffer: It doesn't
@@ -1690,15 +1681,7 @@ other_buffer_safely (Lisp_Object buffer)
if (candidate_buffer (buf, buffer))
return buf;
- AUTO_STRING (scratch, "*scratch*");
- buf = Fget_buffer (scratch);
- if (NILP (buf))
- {
- buf = Fget_buffer_create (scratch, Qnil);
- Fset_buffer_major_mode (buf);
- }
-
- return buf;
+ return safe_call (1, Qget_scratch_buffer_create);
}
DEFUN ("buffer-enable-undo", Fbuffer_enable_undo, Sbuffer_enable_undo,
@@ -5583,6 +5566,7 @@ syms_of_buffer (void)
DEFSYM (Qbefore_change_functions, "before-change-functions");
DEFSYM (Qafter_change_functions, "after-change-functions");
DEFSYM (Qkill_buffer_query_functions, "kill-buffer-query-functions");
+ DEFSYM (Qget_scratch_buffer_create, "get-scratch-buffer-create");
DEFSYM (Qvertical_scroll_bar, "vertical-scroll-bar");
Fput (Qvertical_scroll_bar, Qchoice, list4 (Qnil, Qt, Qleft, Qright));