unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Xiyue Deng <manphiz@gmail.com>
To: 67848@debbugs.gnu.org
Subject: bug#67848: 29.1; Fix usage of `setq-default' and add explanation
Date: Sat, 16 Dec 2023 03:26:30 -0800	[thread overview]
Message-ID: <87fs02ie1l.fsf@debian-hx90.lan> (raw)
In-Reply-To: <87msuaief7.fsf@debian-hx90.lan> (Xiyue Deng's message of "Sat, 16 Dec 2023 03:18:20 -0800")

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: 0001-Fix-usage-of-setq-default-and-add-explanation-bug-67.patch --]
[-- Type: text/x-diff, Size: 1903 bytes --]

From 197467583063492dee7bc2fc40709ecb3a3d17e9 Mon Sep 17 00:00:00 2001
From: Xiyue Deng <manphiz@gmail.com>
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






  reply	other threads:[~2023-12-16 11:26 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-16 11:18 bug#67848: 29.1; Fix usage of `setq-default' and add explanation Xiyue Deng
2023-12-16 11:26 ` Xiyue Deng [this message]
2023-12-23  9:00 ` Eli Zaretskii
2023-12-23 10:09   ` Xiyue Deng
2023-12-23 11:20     ` Eli Zaretskii
2023-12-24  7:00       ` Xiyue Deng
2023-12-24  8:47         ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87fs02ie1l.fsf@debian-hx90.lan \
    --to=manphiz@gmail.com \
    --cc=67848@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).