From 63cfabae39f03552f28b037c6a4c558233c6ff77 Mon Sep 17 00:00:00 2001 From: Gerd Moellmann Date: Thu, 1 Nov 2001 10:21:46 +0000 Subject: [PATCH] (Fset_buffer_major_mode): Use initial-major-mode for *scratch*. --- src/ChangeLog | 3 +++ src/buffer.c | 19 ++++++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 747e6a601c4..fbe4f018fa5 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,8 @@ 2001-11-01 Gerd Moellmann + * buffer.c (Fset_buffer_major_mode): Use initial-major-mode for + *scratch*. + * xfaces.c (Finternal_set_lisp_face_attribute_from_resource): Handle :box so that it is possible to specify sexprs. diff --git a/src/buffer.c b/src/buffer.c index a20b2250209..902d818f230 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -1444,7 +1444,9 @@ record_buffer (buf) } DEFUN ("set-buffer-major-mode", Fset_buffer_major_mode, Sset_buffer_major_mode, 1, 1, 0, - "Set an appropriate major mode for BUFFER, according to `default-major-mode'.\n\ + "Set an appropriate major mode for BUFFER.\n\ +For the *scratch* buffer use `initial-major-mode', otherwise choose a\n\ +mode according to `default-major-mode'.\n\ Use this function before selecting the buffer, since it may need to inspect\n\ the current buffer's major mode.") (buffer) @@ -1453,10 +1455,17 @@ the current buffer's major mode.") int count; Lisp_Object function; - function = buffer_defaults.major_mode; - if (NILP (function) && NILP (Fget (current_buffer->major_mode, Qmode_class))) - function = current_buffer->major_mode; - + if (STRINGP (XBUFFER (buffer)->name) + && strcmp (XSTRING (XBUFFER (buffer)->name)->data, "*scratch*") == 0) + function = find_symbol_value (intern ("initial-major-mode")); + else + { + function = buffer_defaults.major_mode; + if (NILP (function) + && NILP (Fget (current_buffer->major_mode, Qmode_class))) + function = current_buffer->major_mode; + } + if (NILP (function) || EQ (function, Qfundamental_mode)) return Qnil; -- 2.39.2