Subject: bug#67848: 29.1; Fix usage of `setq-default' and add explanation

From: Xiyue Deng <[email-masked]>
Date: Sat, 16 Dec 2023 03:26:30 -0800

>From 197467583063492dee7bc2fc40709ecb3a3d17e9 Mon Sep 17 00:00:00 2001
From: Xiyue Deng <[email-masked]>
Date: Sat, 16 Dec 2023 02:06:15 -0800
Subject: [PATCH] Fix usage of `setq-default' and add explanation (bug#67848)

cd61af0 changed from default-major-mode to major-mode in the first
code sample but didn't change the rest.  Fix it here and add some
explanations of why use `setq-default' instead of `setq'.

* doc/lispintro/emacs-lisp-intro.texi (Text and Auto-fill): fix `setq'
to `setq-default' and add some explanations.
---
 doc/lispintro/emacs-lisp-intro.texi | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/doc/lispintro/emacs-lisp-intro.texi b/doc/lispintro/emacs-lisp-intro.texi
index eb8ff413b79..2468571eb96 100644
--- a/doc/lispintro/emacs-lisp-intro.texi
+++ b/doc/lispintro/emacs-lisp-intro.texi
@@ -16943,14 +16943,19 @@ Here is the line again; how does it work?
 
 @cindex Text Mode turned on
 @smallexample
-(setq major-mode 'text-mode)
+(setq-default major-mode 'text-mode)
 @end smallexample
 
 @noindent
 This line is a short, but complete Emacs Lisp expression.
 
-We are already familiar with @code{setq}.  It sets the following variable,
-@code{major-mode}, to the subsequent value, which is @code{text-mode}.
+We are already familiar with @code{setq}.  We use a similar macro
+@code{setq-default} to set the following variable,
+@code{major-mode}@footnote{We use @code{setq-default} because
+@code{text-mode} is buffer local.  If we use @code{setq} it will only
+apply to the current buffer, and using @code{setq-default} will also
+apply this to newly created buffers.}, to the subsequent value, which is
+@code{text-mode}.
 The single-quote before @code{text-mode} tells Emacs to deal directly
 with the @code{text-mode} symbol, not with whatever it might stand for.
 @xref{set & setq, , Setting the Value of a Variable},
-- 
2.39.2