From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Xiyue Deng Newsgroups: gmane.emacs.bugs Subject: bug#67848: 29.1; Fix usage of `setq-default' and add explanation Date: Sat, 16 Dec 2023 03:26:30 -0800 Message-ID: <87fs02ie1l.fsf@debian-hx90.lan> References: <87msuaief7.fsf@debian-hx90.lan> Mime-Version: 1.0 Content-Type: text/x-diff Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32676"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) To: 67848@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Dec 16 12:27:28 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rESpM-0008N3-61 for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 16 Dec 2023 12:27:28 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rESoy-0001kJ-QX; Sat, 16 Dec 2023 06:27:04 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rESov-0001i6-Tu for bug-gnu-emacs@gnu.org; Sat, 16 Dec 2023 06:27:01 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rESov-0002YP-GH for bug-gnu-emacs@gnu.org; Sat, 16 Dec 2023 06:27:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rESow-0005sV-0H for bug-gnu-emacs@gnu.org; Sat, 16 Dec 2023 06:27:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Xiyue Deng Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 16 Dec 2023 11:27:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67848 X-GNU-PR-Package: emacs Original-Received: via spool by 67848-submit@debbugs.gnu.org id=B67848.170272600022562 (code B ref 67848); Sat, 16 Dec 2023 11:27:01 +0000 Original-Received: (at 67848) by debbugs.gnu.org; 16 Dec 2023 11:26:40 +0000 Original-Received: from localhost ([127.0.0.1]:54044 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rESoa-0005rq-1k for submit@debbugs.gnu.org; Sat, 16 Dec 2023 06:26:40 -0500 Original-Received: from mail-io1-xd34.google.com ([2607:f8b0:4864:20::d34]:48485) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rESoX-0005rQ-Rw for 67848@debbugs.gnu.org; Sat, 16 Dec 2023 06:26:38 -0500 Original-Received: by mail-io1-xd34.google.com with SMTP id ca18e2360f4ac-7b3b819f8a3so84018939f.1 for <67848@debbugs.gnu.org>; Sat, 16 Dec 2023 03:26:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702725991; x=1703330791; darn=debbugs.gnu.org; h=content-disposition:mime-version:user-agent:message-id:date :references:in-reply-to:subject:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9ndBqhpRFW1UxXGnnVfJd6wt0eF7i7ASWQ4yajd1pKM=; b=nIzoVBcY4rj28JyviTPHLCaYotEqCTIL+wtOSE1FdzdA0t/rLE/kyJg8VXMIO3XEMN fcUP0SZWGtOFp7chInMFkuFyVHiXlaBauhci+1LfNJTpZZpfA7KHbOHDfmCtZ0fHJ5z+ WRqzFalmd43sWAHnY8MokLOGVMScX/idjFlKrJICpPuH/szXOBJ26cieKd4d6ntfs0dX VcGXQvqwwM/eP5i/0pHlqgmBPssxjMPCQw+KfDIDSY9H51+/jMDp9Nf3RA7141Q/mgYL 0v31UXy080GfuSyOPtnKWuFTN1EXMIO/1TS5gvj/VKi2nHTAeyDlgJtZT4MzRGIEKiJV yMZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702725991; x=1703330791; h=content-disposition:mime-version:user-agent:message-id:date :references:in-reply-to:subject:to:from:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=9ndBqhpRFW1UxXGnnVfJd6wt0eF7i7ASWQ4yajd1pKM=; b=DvBNnHXGuyxNiN6d2pMwfoGdoBaMhUspSZ5vLRbOB1eW1NqCuC8ALoogpcjSXOKDZc 0w211gl7OJF752WfEwKQoLlO4Oi6/z7ae5sNAGpz/De42mbK3Utx8TnqkojPmvj1p0Y7 WmLynTDpBuFjmZxAUs4BQm/6rgeyTiZN0Y26gABAsbz+gBdvTf+1WchxJm6WZqW5iJcX azxLalsCU3kbUJYFtnvETxJ45/KUfBGjEOgvhd4Ch23KCzh7iHpYq226QUfki04VcGKn gB8yL2GTuIJ4V6z0tuP/EkhhyV64urQaZEhkqPAPBh/zXICp3ouosW84oICthm8AmDj0 nktw== X-Gm-Message-State: AOJu0Yw9VyFPezQ318WDTSv9MWj/S0LB63hbknkQEbOeOwQ2NWO0yMNZ TLRPiIiO4gFOeWsYCWA17+VRtZwZR4c= X-Google-Smtp-Source: AGHT+IHHFJhmyveP1v76YQLATOEJ73UzcnF/MDwGfw7y/EbbSBMDreNn3XNYoQbBb96ElxcJkz3LvA== X-Received: by 2002:a05:6e02:1522:b0:35f:77c5:5e6c with SMTP id i2-20020a056e02152200b0035f77c55e6cmr6030729ilu.118.1702725991353; Sat, 16 Dec 2023 03:26:31 -0800 (PST) Original-Received: from debian-hx90 (2603-8000-a400-0cdc-4892-4b94-aebd-88a9.res6.spectrum.com. [2603:8000:a400:cdc:4892:4b94:aebd:88a9]) by smtp.gmail.com with ESMTPSA id p4-20020a634204000000b005b856fab5e9sm14468820pga.18.2023.12.16.03.26.30 for <67848@debbugs.gnu.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Dec 2023 03:26:30 -0800 (PST) In-Reply-To: <87msuaief7.fsf@debian-hx90.lan> (Xiyue Deng's message of "Sat, 16 Dec 2023 03:18:20 -0800") Content-Disposition: attachment; filename=0001-Fix-usage-of-setq-default-and-add-explanation-bug-67.patch X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:276314 Archived-At: >From 197467583063492dee7bc2fc40709ecb3a3d17e9 Mon Sep 17 00:00:00 2001 From: Xiyue Deng 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